hugo_import
hugo_import(name, add_front_matter, path, src)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
add_front_matter | If this is non-empty, then the imported file is actually a new file whose contents are created by prepending this string (plus a newline) to the beginning of the src file’s contents. The new file will be placed in this target’s package and with this target’s name .This attribute may be useful for adding a front matter section to Bazel-generated files which don’t already have a front matter section. (E.g., you want to include a file is generated by stardoc in your Hugo website, but the stardoc -generated file doesn’t have a front matter section).If this is set to the empty string (the default value), no copying is performed, i.e., the src file is imported and used without copying or modifying it.Note that this does not check to see whether the src file already has a front matter section or modify one if it already exists. |
String | optional | "” |
path | String | required | ||
src | Label | required |
hugo_library
hugo_library(name, deps, srcs)
A hugo_library
represents a Hugo website fragment. It is essentially a
collection of Hugo source files and their corresponding paths relative to a
Hugo website root.
A hugo_library
target lets you wrap multiple related source files, organize
them into a file hierarchy, and provide them as one to hugo_website
targets.
Note that this rule is not involved in building Hugo websites or website
fragments. It is only a collection of Hugo website source files. The sources in
a hugo_library
are only built within the source tree of a hugo_website
in
which they have been included.
A hugo_library
target takes its Bazel package to be the root directory of a
collection of Hugo source files. For each of the source files in srcs
, the
file’s path relative to this root is recorded and used to later place that
source file within Hugo websites.
A hugo_library
is included in a hugo_website
by including it in a website’s
deps
attribute. Doing so means that each file in the hugo_library
should
be placed into the source tree of that hugo_website
; specifically, each
file is placed at its corresponding path
relative to the website’s root.
This way in which the hugo_library
target’s package is used as a website
root is quite like hugo_website
targets.
Also like hugo_website
, srcs
must be in this Bazel package or a Bazel
subpackage. Otherwise, analysis of this target will fail.
Note that the hugo_website
will fail if two of its source files are mapped
to the same path within its source tree. Thus both the contents and paths of
files are part of a hugo_library
's public interface.
This rule will fail if two of its source files are mapped to the same relative path.
This rule will fail if no sources are provided (i.e. srcs
is empty and there
are no sources provided by any deps
).
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of targets providing HugoSourcesInfo (e.g. hugo_library s and hugo_import s) whose sources should be included in this hugo_library target and any Hugo targets which depend upon this target. |
List of labels | optional | [] |
srcs | A list of source files to include in this target. All of these source files should be in this target’s package or one of its subpackages. | List of labels | optional | [] |
hugo_toolchain
hugo_toolchain(name, hugo)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
hugo | The hugo executable (in the host configuration) to use to build Hugo websites. |
Label | optional | None |
hugo_website
hugo_website(name, deps, srcs)
A simple rule which builds a Hugo website with the hugo
command. The output
directory is named the same as the rule’s name attribute.
A hugo_website
's Bazel package is taken to be the Hugo website’s root
directory. This means that the Bazel BUILD
file declaring the hugo_website
should be a siblings of its Hugo top-level files & directories (e.g.,
config.toml
, content/
, layouts/
, etc).
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | A list of targets providing HugoSourcesInfo (e.g. hugo_library s and hugo_import s) whose sources should be included in this hugo_website . |
List of labels | optional | [] |
srcs | A list of files to be included in the website. Be aware that the rule will fail if a source file given here is located outside of this hugo_website 's package or subpackages.A glob() expression may be an appropriate value for this attribute, but be aware that Bazel glob s do not reach into Bazel subpackages. |
List of labels | optional | [] |
local_hugo_repository
local_hugo_repository(name)
Searches the system PATH
for a hugo
executable. If it is not found, then this rule fails. If it is found, then this executable is symlinked into the root of this external repository. Additionally, a hugo_toolchain
(labeled //:hugo_toolchain
) is synthesized in the root package of this external repository to wrap this executable symlink. This toolchain can be registered with the helper macro //:defs.bzl%register_hugo_toolchain
.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required |