hugo
Build runs Hugo (extended edition, official image pinned by digest) on a site's sourcedirectory and returns the built site (Hugo's public/ directory); with npm it first installs
the site's Node dependencies from its package-lock.json (themes such as Docsy take
Bootstrap, Font Awesome and Dart Sass from node_modules). Index adds a Pagefind
search index, Linkcheck checks the built site's links with lychee, and Archive packs the
site as a tarball. The built directory is what GitHub Pages and GitLab Pages publish.
Installation
dagger install github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4Entrypoint
Return Type
Hugo !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| container | Container | - | container is an existing container with hugo (and go, for Hugo modules) on PATH |
| lychee | Container | - | lychee is an existing container with lychee on PATH |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
func (m *MyModule) Example() *dagger.Hugo {
return dag.
Hugo()
}@function
def example() -> dagger.Hugo:
return (
dag.hugo()
)@func()
example(): Hugo {
return dag
.hugo()
}Types
Hugo 🔗
Hugo builds and checks Hugo sites.
container() 🔗
Container has hugo on PATH and runs as a user that owns /src, /tmp and /cache.
Return Type
Container ! Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
containerfunc (m *MyModule) Example() *dagger.Container {
return dag.
Hugo().
Container()
}@function
def example() -> dagger.Container:
return (
dag.hugo()
.container()
)@func()
example(): Container {
return dag
.hugo()
.container()
}lychee() 🔗
Lychee has lychee on PATH.
Return Type
Container ! Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
lycheefunc (m *MyModule) Example() *dagger.Container {
return dag.
Hugo().
Lychee()
}@function
def example() -> dagger.Container:
return (
dag.hugo()
.lychee()
)@func()
example(): Container {
return dag
.hugo()
.lychee()
}archive() 🔗
Archive packs a built site into a gzipped tarball whose files are under prefix (GitLab Pages publishes public/; a GitHub Pages artifact is the site’s content).
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| site | Directory ! | - | site is a built site |
| prefix | String ! | "public" | prefix is the directory the files are under in the archive; empty puts them at the top |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
archive --site DIR_PATH --prefix stringfunc (m *MyModule) Example(site *dagger.Directory, prefix string) *dagger.File {
return dag.
Hugo().
Archive(site, prefix)
}@function
def example(site: dagger.Directory, prefix: str) -> dagger.File:
return (
dag.hugo()
.archive(site, prefix)
)@func()
example(site: Directory, prefix: string): File {
return dag
.hugo()
.archive(site, prefix)
}build() 🔗
Build runs hugo on source and returns the built site (the content of public/).
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | source is the site’s project directory (hugo.yaml or config/, content/, …), or a directory that contains it (see path) |
| path | String ! | "." | path is the project directory within source, for a site whose module mounts reach outside it (e.g. source is the repository and path is docs/site) |
| environment | String ! | "production" | environment is Hugo’s environment (–environment) |
| baseUrl | String | - | baseURL overrides the site’s baseURL, e.g. https://docs.example.com/ or /group/project/ |
| minify | Boolean ! | true | minify minifies the HTML, CSS, JS, JSON and SVG output |
| extraArgs | [String ! ] | - | extraArgs are additional hugo arguments, e.g. [“–panicOnWarning”] or ”–config”, “hugo.yaml,more.yaml” |
| npm | Boolean ! | false | npm runs npm ci in the project directory first (it needs a package-lock.json) and puts its node_modules/.bin first on PATH, so a pinned sass-embedded is the Dart Sass Hugo uses |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
build --source DIR_PATH --path string --environment string --minify boolean --npm booleanfunc (m *MyModule) Example(source *dagger.Directory, path string, environment string, minify bool, npm bool) *dagger.Directory {
return dag.
Hugo().
Build(source, path, environment, minify, npm)
}@function
def example(source: dagger.Directory, path: str, environment: str, minify: bool, npm: bool) -> dagger.Directory:
return (
dag.hugo()
.build(source, path, environment, minify, npm)
)@func()
example(source: Directory, path: string, environment: string, minify: boolean, npm: boolean): Directory {
return dag
.hugo()
.build(source, path, environment, minify, npm)
}index() 🔗
Index adds a Pagefind search index to a built site (in pagefind/, with Pagefind’s UI scripts) and returns the site.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| site | Directory ! | - | site is a built site (Build’s output) |
| extraArgs | [String ! ] | - | extraArgs are additional pagefind arguments, e.g. [“–exclude-selectors”, “nav”] |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
index --site DIR_PATHfunc (m *MyModule) Example(site *dagger.Directory) *dagger.Directory {
return dag.
Hugo().
Index(site)
}@function
def example(site: dagger.Directory) -> dagger.Directory:
return (
dag.hugo()
.index(site)
)@func()
example(site: Directory): Directory {
return dag
.hugo()
.index(site)
}linkcheck() 🔗
Linkcheck checks the links in a built site’s HTML with lychee and returns its report. Internal links (files, root-relative paths, and with fragments their #anchors) are always checked, offline; external links only with external. It fails on a broken link.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| site | Directory ! | - | site is a built site (Build’s output) |
| external | Boolean ! | false | external also checks http(s) links (needs network; slower and less deterministic) |
| fragments | Boolean ! | true | fragments checks that #anchors exist in the linked pages |
| basePath | String | - | basePath is the URL path the site is served under when not /, e.g. /group/project/ |
| exclude | [String ! ] | - | exclude are regular expressions of URLs not to check, e.g. [“^https://github\.com/org/private”] |
| extraArgs | [String ! ] | - | extraArgs are additional lychee arguments |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
linkcheck --site DIR_PATH --external boolean --fragments booleanfunc (m *MyModule) Example(ctx context.Context, site *dagger.Directory, external bool, fragments bool) string {
return dag.
Hugo().
Linkcheck(ctx, site, external, fragments)
}@function
async def example(site: dagger.Directory, external: bool, fragments: bool) -> str:
return await (
dag.hugo()
.linkcheck(site, external, fragments)
)@func()
async example(site: Directory, external: boolean, fragments: boolean): Promise<string> {
return dag
.hugo()
.linkcheck(site, external, fragments)
}site() 🔗
Site builds source and, with index, adds the Pagefind search index: Build then Index.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | source is the site’s project directory, or a directory that contains it (see path) |
| path | String ! | "." | path is the project directory within source |
| environment | String ! | "production" | environment is Hugo’s environment (–environment) |
| baseUrl | String | - | baseURL overrides the site’s baseURL |
| index | Boolean ! | true | index adds the Pagefind search index |
| extraArgs | [String ! ] | - | extraArgs are additional hugo arguments |
| npm | Boolean ! | false | npm installs the site’s Node dependencies first (see Build) |
Example
dagger -m github.com/hampusctl/daggerverse/hugo@c2266703ee2732180eb1e111a2a82452045817f4 call \
site --source DIR_PATH --path string --environment string --index boolean --npm booleanfunc (m *MyModule) Example(source *dagger.Directory, path string, environment string, index bool, npm bool) *dagger.Directory {
return dag.
Hugo().
Site(source, path, environment, index, npm)
}@function
def example(source: dagger.Directory, path: str, environment: str, index: bool, npm: bool) -> dagger.Directory:
return (
dag.hugo()
.site(source, path, environment, index, npm)
)@func()
example(source: Directory, path: string, environment: string, index: boolean, npm: boolean): Directory {
return dag
.hugo()
.site(source, path, environment, index, npm)
}