Links


Hugo

In the content

A link to another page in the site, use a built-in shortcut:

[text]({{< ref "page-file-name" >}})

In the templates

Functions

Do not use a leading slash in path.

baseURL = "http://example.org/"
{{ absURL "path" }}  -> http://example.org/path
{{ relURL "path" }}  -> /path
baseURL = "http://example.org/dir"
{{ absURL "path" }}  -> http://example.org/dir/path
{{ relURL "path" }}  -> /dir/path

Methods

baseURL = "http://example.org/"
{{ $page := .Site.GetPage "page" }}
{{ $page.Permalink }}     -> http://example.org/page
{{ $page.Relpermalink }}  -> /page
baseURL = "http://example.org/dir"
{{ $page := .Site.GetPage "page" }}
{{ $page.Permalink }}     -> http://example.org/dir/page
{{ $page.Relpermalink }}  -> /dir/page

baseURL

baseURL = scheme : net_loc / [path/]

hugo server overrides baseURL to http://localhost:1313/

baseURL is prepended to .Permalink and ref. /path is prepended to .RelPermalink and relref.

Serverless version

To navigate the website using the file system, set relativeURLs = true:

hugo
cd public
firefox index.html

Alternate server

cd public
python3 -m http.server