hugo/docs/content/en/templates/single.md
2024-08-09 15:17:43 +02:00

1.5 KiB

title description categories keywords menu weight toc aliases
Single templates Create a single template to render a single page.
templates
docs
parent weight
templates 70
70 true
/layout/content/
/templates/single-page-templates/

The single template below inherits the site's shell from the base template.

{{< code file=layouts/_default/single.html >}} {{ define "main" }}

{{ .Title }}

{{ .Content }} {{ end }} {{< /code >}}

Review the template lookup order to select a template path that provides the desired level of specificity.

The single template below inherits the site's shell from the base template, and renders the page title, creation date, content, and a list of associated terms in the "tags" taxonomy.

{{< code file=layouts/_default/single.html >}} {{ define "main" }}

{{ .Title }}

{{ with .Date }} {{ $dateMachine := . | time.Format "2006-01-02T15:04:05-07:00" }} {{ $dateHuman := . | time.Format ":date_long" }} {{ end }}
{{ .Content }}
{{ end }} {{< /code >}}