Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bazel build rules for hugo static website generator

License

NotificationsYou must be signed in to change notification settings

stackb/rules_hugo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

RulesHugo

Bazel rules for building static websites withHugo.

Repository Rules

NameDescription
hugo_repositoryLoad hugo dependency for this repo.
github_hugo_themeLoad a hugo theme from github.

Build Rules

NameDescription
hugo_siteDeclare a hugo site.
hugo_themeDeclare a hugo theme.

Usage

Add rules_hugo to your WORKSPACE and add a theme from github

# Update these to latestRULES_HUGO_COMMIT="..."RULES_HUGO_SHA256="..."http_archive(name="build_stack_rules_hugo",url="https://github.com/stackb/rules_hugo/archive/%s.zip"%RULES_HUGO_COMMIT,sha256=RULES_HUGO_SHA256,strip_prefix="rules_hugo-%s"%RULES_HUGO_COMMIT)load("@build_stack_rules_hugo//hugo:rules.bzl","hugo_repository","github_hugo_theme")## Load hugo binary itself## Optionally, load a specific version of Hugo, with the 'version' argumenthugo_repository(name="hugo",)## This makes a filegroup target "@com_github_yihui_hugo_xmin//:files"# available to your build files#github_hugo_theme(name="com_github_yihui_hugo_xmin",owner="yihui",repo="hugo-xmin",commit="c14ca049d0dd60386264ea68c91d8495809cc4c6",)## This creates a filegroup target from a released archive from GitHub# this is useful when a theme uses compiled / aggregated sources NOT found# in a source root.#http_archive(name="com_github_thegeeklab_hugo_geekdoc",url="https://github.com/thegeeklab/hugo-geekdoc/releases/download/v0.34.2/hugo-geekdoc.tar.gz",sha256="7fdd57f7d4450325a778629021c0fff5531dc8475de6c4ec70ab07e9484d400e",build_file_content="""filegroup(    name = "files",    srcs = glob(["**"]),    visibility = ["//visibility:public"])    """)

Declare a hugo_site with a GitHub repository theme in your BUILD file

load("@build_stack_rules_hugo//hugo:rules.bzl","hugo_site","hugo_theme","hugo_serve")# Declare a theme 'xmin'.  In this case the `name` and# `theme_name` are identical, so the `theme_name` could be omitted in this case.hugo_theme(name="xmin",theme_name="xmin",srcs= ["@com_github_yihui_hugo_xmin//:files",    ],)# Declare a site. Config file is required.my_site_name="basic"hugo_site(name=my_site_name,config="config.toml",content= ["_index.md","about.md",    ],quiet=False,theme=":xmin",)# Run local development serverhugo_serve(name="local_%s"%my_site_name,dep= [":%s"%my_site_name],)# Tar it uppkg_tar(name="%s_tar"%my_site_name,srcs= [":%s"%my_site_name],)

Declare a hugo_site with a GitHub released archive theme in your BUILD file

load("@build_stack_rules_hugo//hugo:rules.bzl","hugo_site","hugo_theme","hugo_serve")hugo_theme(name="hugo_theme_geekdoc",theme_name="hugo-geekdoc",srcs= ["@com_github_thegeeklab_hugo_geekdoc//:files",    ],)# Note, here we are using the config_dir attribute to support multi-lingual configurations.hugo_site(name="site_complex",config_dir=glob(["config/**"]),content=glob(["content/**"]),data=glob(["data/**"]),quiet=False,theme=":hugo_theme_geekdoc",)# Run local development serverhugo_serve(name="serve",dep= [":site_complex"],)

Previewing the site

Execute the following command:

bazel run //site_complex:serve

Then open your browser:here

Build the site

Thehugo_site target emits the output in thebazel-bin directory.

$ bazel build :basic[...]Target //:basic up-to-date:  bazel-bin/basic[...]
$ tree bazel-bin/basicbazel-bin/basic├── 404.html├── about│   └── index.html[...]

Thepkg_tar target emits a%{name}_tar.tar file containing all the Hugo output files.

$ bazel build :basic_tar[...]Target //:basic up-to-date:  bazel-bin/basic_tar.tar

End

See source code for details about additional rule attributes / parameters.

About

Bazel build rules for hugo static website generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors14

Languages


[8]ページ先頭

©2009-2025 Movatter.jp