Dagger
Search

hugo

Build runs Hugo (extended edition, official image pinned by digest) on a site's source
directory and returns the built site (Hugo's public/ directory). 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@afe8c6f672c9b455a93545e0f3204db4ddf63551

Entrypoint

Return Type
Hugo !
Arguments
NameTypeDefault ValueDescription
containerContainer -container is an existing container with hugo (and go, for Hugo modules) on PATH
lycheeContainer -lychee is an existing container with lychee on PATH
Example
dagger -m github.com/hampusctl/daggerverse/hugo@afe8c6f672c9b455a93545e0f3204db4ddf63551 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@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 container
func (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@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 lychee
func (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
NameTypeDefault ValueDescription
siteDirectory !-

site is a built site

prefixString !"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@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 archive --site DIR_PATH --prefix string
func (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
NameTypeDefault ValueDescription
sourceDirectory !-

source is the site’s project directory (hugo.yaml or config/, content/, …), or a directory that contains it (see path)

pathString !"."

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)

environmentString !"production"

environment is Hugo’s environment (–environment)

baseUrlString -

baseURL overrides the site’s baseURL, e.g. https://docs.example.com/ or /group/project/

minifyBoolean !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”

Example
dagger -m github.com/hampusctl/daggerverse/hugo@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 build --source DIR_PATH --path string --environment string --minify boolean
func (m *MyModule) Example(source *dagger.Directory, path string, environment string, minify bool) *dagger.Directory  {
	return dag.
			Hugo().
			Build(source, path, environment, minify)
}
@function
def example(source: dagger.Directory, path: str, environment: str, minify: bool) -> dagger.Directory:
	return (
		dag.hugo()
		.build(source, path, environment, minify)
	)
@func()
example(source: Directory, path: string, environment: string, minify: boolean): Directory {
	return dag
		.hugo()
		.build(source, path, environment, minify)
}

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
NameTypeDefault ValueDescription
siteDirectory !-

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@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 index --site DIR_PATH
func (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
NameTypeDefault ValueDescription
siteDirectory !-

site is a built site (Build’s output)

externalBoolean !false

external also checks http(s) links (needs network; slower and less deterministic)

fragmentsBoolean !true

fragments checks that #anchors exist in the linked pages

basePathString -

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@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 linkcheck --site DIR_PATH --external boolean --fragments boolean
func (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
NameTypeDefault ValueDescription
sourceDirectory !-

source is the site’s project directory, or a directory that contains it (see path)

pathString !"."

path is the project directory within source

environmentString !"production"

environment is Hugo’s environment (–environment)

baseUrlString -

baseURL overrides the site’s baseURL

indexBoolean !true

index adds the Pagefind search index

extraArgs[String ! ] -

extraArgs are additional hugo arguments

Example
dagger -m github.com/hampusctl/daggerverse/hugo@afe8c6f672c9b455a93545e0f3204db4ddf63551 call \
 site --source DIR_PATH --path string --environment string --index boolean
func (m *MyModule) Example(source *dagger.Directory, path string, environment string, index bool) *dagger.Directory  {
	return dag.
			Hugo().
			Site(source, path, environment, index)
}
@function
def example(source: dagger.Directory, path: str, environment: str, index: bool) -> dagger.Directory:
	return (
		dag.hugo()
		.site(source, path, environment, index)
	)
@func()
example(source: Directory, path: string, environment: string, index: boolean): Directory {
	return dag
		.hugo()
		.site(source, path, environment, index)
}