From fd628be6ed3f1150d0030ba1424cc8f2da72efbb Mon Sep 17 00:00:00 2001
From: Joe Mooring Related content: Tags Related content: {{ . }} is even {{ . }} is odd Related pages: The page you requested cannot be found.{{ .LinkTitle }}
{{ end }}
-{{< /code >}}
+```
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ with .Prev }}
Previous
{{ end }}
@@ -46,7 +46,7 @@ And these templates:
{{ with .Next }}
Next
{{ end }}
-{{< /code >}}
+```
When you visit page-2:
diff --git a/content/en/_common/methods/page/nextinsection-and-previnsection.md b/content/en/_common/methods/page/nextinsection-and-previnsection.md
index 3d87a2d7a..54d240eb4 100644
--- a/content/en/_common/methods/page/nextinsection-and-previnsection.md
+++ b/content/en/_common/methods/page/nextinsection-and-previnsection.md
@@ -32,13 +32,13 @@ content/
And these templates:
-{{< code file=layouts/_default/list.html >}}
+```go-html-template {file="layouts/_default/list.html"}
{{ range .Pages.ByWeight }}
{{ .LinkTitle }}
{{ end }}
-{{< /code >}}
+```
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ with .PrevInSection }}
Previous
{{ end }}
@@ -46,7 +46,7 @@ And these templates:
{{ with .NextInSection }}
Next
{{ end }}
-{{< /code >}}
+```
When you visit page-2:
diff --git a/content/en/_common/methods/pages/next-and-prev.md b/content/en/_common/methods/pages/next-and-prev.md
index 621d6b079..462545c3f 100644
--- a/content/en/_common/methods/pages/next-and-prev.md
+++ b/content/en/_common/methods/pages/next-and-prev.md
@@ -32,13 +32,13 @@ content/
And these templates:
-{{< code file=layouts/_default/list.html >}}
+```go-html-template {file="layouts/_default/list.html"}
{{ range .Pages.ByWeight }}
{{ .LinkTitle }}
{{ end }}
-{{< /code >}}
+```
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ $pages := .CurrentSection.Pages.ByWeight }}
{{ with $pages.Prev . }}
@@ -48,7 +48,7 @@ And these templates:
{{ with $pages.Next . }}
Next
{{ end }}
-{{< /code >}}
+```
When you visit page-2:
@@ -57,7 +57,7 @@ When you visit page-2:
To reverse the meaning of _next_ and _previous_ you can chain the [`Reverse`] method to the page collection definition:
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ $pages := .CurrentSection.Pages.ByWeight.Reverse }}
{{ with $pages.Prev . }}
@@ -67,6 +67,6 @@ To reverse the meaning of _next_ and _previous_ you can chain the [`Reverse`] me
{{ with $pages.Next . }}
Next
{{ end }}
-{{< /code >}}
+```
[`Reverse`]: /methods/pages/reverse/
diff --git a/content/en/_common/methods/taxonomy/get-a-taxonomy-object.md b/content/en/_common/methods/taxonomy/get-a-taxonomy-object.md
index d52f7ee4c..6fb729c17 100644
--- a/content/en/_common/methods/taxonomy/get-a-taxonomy-object.md
+++ b/content/en/_common/methods/taxonomy/get-a-taxonomy-object.md
@@ -34,9 +34,9 @@ To capture the "genres" `Taxonomy` object from within any template, use the [`Ta
To capture the "genres" `Taxonomy` object when rendering its page with a taxonomy template, use the [`Terms`] method on the page's [`Data`] object:
-{{< code file=layouts/_default/taxonomy.html >}}
+```go-html-template {file="layouts/_default/taxonomy.html"}
{{ $taxonomyObject := .Data.Terms }}
-{{< /code >}}
+```
To inspect the data structure:
diff --git a/content/en/_common/render-hooks/pageinner.md b/content/en/_common/render-hooks/pageinner.md
index 29c7eaa2b..ecd50b8a9 100644
--- a/content/en/_common/render-hooks/pageinner.md
+++ b/content/en/_common/render-hooks/pageinner.md
@@ -8,7 +8,7 @@ _comment: Do not remove front matter.
The primary use case for `PageInner` is to resolve links and [page resources](g) relative to an included `Page`. For example, create an "include" shortcode to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents:
-{{< code file=layouts/shortcodes/include.html >}}
+```go-html-template {file="layouts/shortcodes/include.html" copy=true}
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}
@@ -18,13 +18,13 @@ The primary use case for `PageInner` is to resolve links and [page resources](g)
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
{{ end }}
-{{< /code >}}
+```
Then call the shortcode in your Markdown:
-{{< code file=content/posts/p1.md lang=text >}}
+```text {file="content/posts/p1.md"}
{{%/* include "/posts/p2" */%}}
-{{< /code >}}
+```
Any render hook triggered while rendering `/posts/p2` will get:
diff --git a/content/en/configuration/cascade.md b/content/en/configuration/cascade.md
index 403c8f2a7..04723c95a 100644
--- a/content/en/configuration/cascade.md
+++ b/content/en/configuration/cascade.md
@@ -55,7 +55,6 @@ lang
path
: (`string`) A [glob](g) pattern matching the page's [logical path](g). For example: `{/books,/books/**}`.
-
[page language]: /methods/page/language/
## Array
diff --git a/content/en/configuration/http-cache.md b/content/en/configuration/http-cache.md
index bbd092946..862e17ab9 100644
--- a/content/en/configuration/http-cache.md
+++ b/content/en/configuration/http-cache.md
@@ -99,7 +99,6 @@ polls.for.excludes
polls.for.includes
: (`string`) A list of [glob](g) patterns to include in polling for this configuration.
-
## Behavior
Polling and HTTP caching interact as follows:
diff --git a/content/en/configuration/imaging.md b/content/en/configuration/imaging.md
index 021e82ecf..a8fc75a3a 100644
--- a/content/en/configuration/imaging.md
+++ b/content/en/configuration/imaging.md
@@ -19,7 +19,6 @@ quality = 75
resampleFilter = 'box'
{{< /code-toggle >}}
-
anchor
: (`string`) When using the Crop or Fill method, the anchor determines the placement of the crop box. One of `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. Default is `Smart`.
diff --git a/content/en/configuration/markup.md b/content/en/configuration/markup.md
index 4a46e5ba0..fe8982ec3 100644
--- a/content/en/configuration/markup.md
+++ b/content/en/configuration/markup.md
@@ -300,7 +300,7 @@ rougify style monokai.sublime > assets/css/syntax.css
In your base template add a link to the CSS file:
-{{< code file=layouts/_default/baseof.html >}}
+```go-html-template {file="layouts/_default/baseof.html"}
...
{{ with resources.Get "css/syntax.css" }}
@@ -308,7 +308,7 @@ In your base template add a link to the CSS file:
{{ end }}
...
-{{< /code >}}
+```
Then add the code to be highlighted to your markup:
diff --git a/content/en/configuration/menus.md b/content/en/configuration/menus.md
index 533ac9098..f851152a3 100644
--- a/content/en/configuration/menus.md
+++ b/content/en/configuration/menus.md
@@ -97,7 +97,6 @@ pageRef
taxonomy|`/tags`
term|`/tags/foo`
-
url
: (`string`) The destination URL. Use this for external destinations only.
diff --git a/content/en/configuration/module.md b/content/en/configuration/module.md
index dca63a494..2b9add881 100644
--- a/content/en/configuration/module.md
+++ b/content/en/configuration/module.md
@@ -82,7 +82,6 @@ min
[`themesDir`]: /configuration/all/#themesdir
-
## Imports
{{< code-toggle file=hugo >}}
@@ -122,7 +121,6 @@ path
Before Hugo v0.56.0, custom component paths could only be configured by setting [`archetypeDir`], [`assetDir`], [`contentDir`], [`dataDir`], [`i18nDir`], [`layoutDi`], or [`staticDir`] in the site configuration. Module mounts offer greater flexibility than these legacy settings, but
you cannot use both.
-
[`archetypeDir`]: /configuration/all/
[`assetDir`]: /configuration/all/
[`contentDir`]: /configuration/all/
diff --git a/content/en/configuration/output-formats.md b/content/en/configuration/output-formats.md
index e1264e27c..53bfd5b94 100644
--- a/content/en/configuration/output-formats.md
+++ b/content/en/configuration/output-formats.md
@@ -140,7 +140,6 @@ layouts/_default/list.atom.atom
We leave writing the template code as an exercise for you. Aim for a result similar to the [embedded RSS template].
-
## List output formats
To access output formats, each `Page` object provides two methods: [`OutputFormats`] (for all formats, including the current one) and [`AlternativeOutputFormats`]. Use `AlternativeOutputFormats` to create a link `rel` list within your site's `head` element, as shown below:
diff --git a/content/en/configuration/params.md b/content/en/configuration/params.md
index 03308e5d1..239b0c2da 100644
--- a/content/en/configuration/params.md
+++ b/content/en/configuration/params.md
@@ -39,7 +39,6 @@ For example, you can do either of these:
But you cannot do this:
-
```go-html-template
{{ .Site.params.kebab-case.foo }}
```
diff --git a/content/en/configuration/permalinks.md b/content/en/configuration/permalinks.md
index 294b44e15..c2a50df21 100644
--- a/content/en/configuration/permalinks.md
+++ b/content/en/configuration/permalinks.md
@@ -154,7 +154,7 @@ public/
│ │ └── index.html
│ └── index.html
└── index.html
-````
+```
## Tokens
diff --git a/content/en/configuration/related-content.md b/content/en/configuration/related-content.md
index 230231742..18e440ffb 100644
--- a/content/en/configuration/related-content.md
+++ b/content/en/configuration/related-content.md
@@ -101,7 +101,7 @@ We've configured the `authors` index with a weight of `2` and the `genres` index
Then render a list of 5 related reviews with a partial template like this:
-{{< code file=layouts/partials/related.html copy=true >}}
+```go-html-template {file="layouts/partials/related.html" copy=true}
{{ with site.RegularPages.Related . | first 5 }}
@@ -110,4 +110,4 @@ Then render a list of 5 related reviews with a partial template like this:
{{ end }}
{{ end }}
-{{< /code >}}
+```
diff --git a/content/en/configuration/services.md b/content/en/configuration/services.md
index 1c433449f..dbe3893a7 100644
--- a/content/en/configuration/services.md
+++ b/content/en/configuration/services.md
@@ -48,6 +48,5 @@ x.disableInlineCSS
```go-html-template
{{ .Site.Config.Services.X.DisableInlineCSS }}
-
[v0.141.0]: https://github.com/gohugoio/hugo/releases/tag/v0.141.0
[v0.123.0]: https://github.com/gohugoio/hugo/releases/tag/v0.123.0
diff --git a/content/en/content-management/archetypes.md b/content/en/content-management/archetypes.md
index 5e25b54a5..db0838504 100644
--- a/content/en/content-management/archetypes.md
+++ b/content/en/content-management/archetypes.md
@@ -95,7 +95,7 @@ Although typically used as a front matter template, you can also use an archetyp
For example, in a documentation site you might have a section (content type) for functions. Every page within this section should follow the same format: a brief description, the function signature, examples, and notes. We can pre-populate the page to remind content authors of the standard format.
-{{< code file=archetypes/functions.md >}}
+````text {file="archetypes/functions.md"}
---
date: '{{ .Date }}'
draft: true
@@ -119,7 +119,7 @@ One or more practical examples, each within a fenced code block.
## Notes
Additional information to clarify as needed.
-{{< /code >}}
+````
Although you can include [template actions](g) within the content body, remember that Hugo evaluates these once---at the time of content creation. In most cases, place template actions in a [template](g) where Hugo evaluates the actions every time you [build](g) the site.
diff --git a/content/en/content-management/build-options.md b/content/en/content-management/build-options.md
index c003347ed..e3bdeaab8 100644
--- a/content/en/content-management/build-options.md
+++ b/content/en/content-management/build-options.md
@@ -79,14 +79,14 @@ title = 'Headless page'
To include the content and images on the home page:
-{{< code file=layouts/_default/home.html >}}
+```go-html-template {file="layouts/_default/home.html"}
{{ with .Site.GetPage "/headless" }}
{{ .Content }}
{{ range .Resources.ByType "image" }}
{{ end }}
{{ end }}
-{{< /code >}}
+```
The published site will have this structure:
@@ -139,7 +139,7 @@ In the front matter above, note that we have set `list` to `local` to include th
To include the content and images on the home page:
-{{< code file=layouts/_default/home.html >}}
+```go-html-template {file="layouts/_default/home.html"}
{{ with .Site.GetPage "/headless" }}
{{ range .Pages }}
{{ .Content }}
@@ -148,7 +148,7 @@ To include the content and images on the home page:
{{ end }}
{{ end }}
{{ end }}
-{{< /code >}}
+```
The published site will have this structure:
@@ -198,14 +198,14 @@ render = 'always'
To render the glossary:
-{{< code file=layouts/glossary/list.html >}}
+```go-html-template {file="layouts/glossary/list.html"}
{{ range .Pages }}
-{{< /code >}}
+```
The published site will have this structure:
@@ -240,7 +240,7 @@ list = 'never'
The published site will have this structure:
-```html
+```text
public/
├── books/
│ ├── book-1/
@@ -289,7 +289,7 @@ environment = 'production'
The production site will have this structure:
-```html
+```text
public/
├── reference/
│ ├── reference-1/
diff --git a/content/en/content-management/content-adapters.md b/content/en/content-management/content-adapters.md
index 1163fb75a..33200272d 100644
--- a/content/en/content-management/content-adapters.md
+++ b/content/en/content-management/content-adapters.md
@@ -37,7 +37,7 @@ Use these methods within a content adapter.
Adds a page to the site.
-{{< code file=content/books/_content.gotmpl >}}
+```go-html-template {file="content/books/_content.gotmpl"}
{{ $content := dict
"mediaType" "text/markdown"
"value" "The _Hunchback of Notre Dame_ was written by Victor Hugo."
@@ -49,13 +49,13 @@ Adds a page to the site.
"title" "The Hunchback of Notre Dame"
}}
{{ .AddPage $page }}
-{{< /code >}}
+```
### AddResource
Adds a page resource to the site.
-{{< code file=content/books/_content.gotmpl >}}
+```go-html-template {file="content/books/_content.gotmpl"}
{{ with resources.Get "images/a.jpg" }}
{{ $content := dict
"mediaType" .MediaType.Type
@@ -67,23 +67,23 @@ Adds a page resource to the site.
}}
{{ $.AddResource $resource }}
{{ end }}
-{{< /code >}}
+```
Then retrieve the new page resource with something like:
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ with .Resources.Get "cover.jpg" }}
{{ end }}
-{{< /code >}}
+```
### Site
Returns the `Site` to which the pages will be added.
-{{< code file=content/books/_content.gotmpl >}}
+```go-html-template {file="content/books/_content.gotmpl"}
{{ .Site.Title }}
-{{< /code >}}
+```
{{< note >}}
Note that the `Site` returned isn't fully built when invoked from the content adapters; if you try to call methods that depends on pages, e.g. `.Site.Pages`, you will get an error saying "this method cannot be called before the site is fully initialized".
@@ -93,16 +93,16 @@ Note that the `Site` returned isn't fully built when invoked from the content ad
Returns a persistent “scratch pad” to store and manipulate data. The main use case for this is to transfer values between executions when [EnableAllLanguages](#enablealllanguages) is set. See [examples](/methods/page/store/).
-{{< code file=content/books/_content.gotmpl >}}
+```go-html-template {file="content/books/_content.gotmpl"}
{{ .Store.Set "key" "value" }}
{{ .Store.Get "key" }}
-{{< /code >}}
+```
### EnableAllLanguages
By default, Hugo executes the content adapter for the language defined by the _content.gotmpl file . Use this method to activate the content adapter for all languages.
-{{< code file=content/books/_content.gotmpl >}}
+```go-html-template {file="content/books/_content.gotmpl"}
{{ .EnableAllLanguages }}
{{ $content := dict
"mediaType" "text/markdown"
@@ -115,7 +115,7 @@ By default, Hugo executes the content adapter for the language defined by the _c
"title" "The Hunchback of Notre Dame"
}}
{{ .AddPage $page }}
-{{< /code >}}
+```
## Page map
@@ -183,7 +183,7 @@ Inspect the remote data to determine how to map key-value pairs to front matter
Create the content adapter.
-{{< code file=content/books/_content.gotmpl copy=true >}}
+```go-html-template {file="content/books/_content.gotmpl" copy=true}
{{/* Get remote data. */}}
{{ $data := dict }}
{{ $url := "https://gohugo.io/shared/examples/data/books.json" }}
@@ -236,13 +236,13 @@ Create the content adapter.
{{ end }}
{{ end }}
-{{< /code >}}
+```
### Step 4
Create a single template to render each book review.
-{{< code file=layouts/books/single.html copy=true >}}
+```go-html-template {file="layouts/books/single.html" copy=true}
{{ define "main" }}
{{ .Title }}
@@ -269,7 +269,7 @@ Create a single template to render each book review.
{{ .Content }}
{{ end }}
-{{< /code >}}
+```
## Multilingual sites
diff --git a/content/en/content-management/data-sources.md b/content/en/content-management/data-sources.md
index 586fcc9d8..b0ce08e41 100644
--- a/content/en/content-management/data-sources.md
+++ b/content/en/content-management/data-sources.md
@@ -59,17 +59,17 @@ See the [`transform.Unmarshal`](/functions/transform/unmarshal/#remote-resource)
Use data sources to augment existing content. For example, create a shortcode to render an HTML table from a global CSV resource.
-{{< code file=assets/pets.csv >}}
+```csv {file="assets/pets.csv"}
"name","type","breed","age"
"Spot","dog","Collie","3"
"Felix","cat","Malicious","7"
-{{< /code >}}
+```
-{{< code file=content/example.md lang=text >}}
+```text {file="content/example.md"}
{{* csv-to-table "pets.csv" */>}}
-{{< /code >}}
+```
-{{< code file=layouts/shortcodes/csv-to-table.html >}}
+```go-html-template {file="layouts/shortcodes/csv-to-table.html"}
{{ with $file := .Get 0 }}
{{ with resources.Get $file }}
{{ with . | transform.Unmarshal }}
@@ -98,7 +98,7 @@ Use data sources to augment existing content. For example, create a shortcode to
{{ else }}
{{ errorf "The %q shortcode requires one positional argument, the path to the CSV file relative to the assets directory. See %s" .Name .Position }}
{{ end }}
-{{< /code >}}
+```
Hugo renders this to:
diff --git a/content/en/content-management/diagrams.md b/content/en/content-management/diagrams.md
index 4c233dbec..e90a7e213 100644
--- a/content/en/content-management/diagrams.md
+++ b/content/en/content-management/diagrams.md
@@ -44,12 +44,12 @@ Hugo does not provide a built-in template for Mermaid diagrams. Create your own
[code block render hook]: /render-hooks/code-blocks/
-{{< code file=layouts/_default/_markup/render-codeblock-mermaid.html >}}
+```go-html-template {file="layouts/_default/_markup/render-codeblock-mermaid.html"}
{{- .Inner | htmlEscape | safeHTML }}
{{ .Page.Store.Set "hasMermaid" true }}
-{{< /code >}}
+```
And then include this snippet at the _bottom_ of the content template, before the closing `body` tag:
diff --git a/content/en/content-management/front-matter.md b/content/en/content-management/front-matter.md
index 954364278..30110c604 100644
--- a/content/en/content-management/front-matter.md
+++ b/content/en/content-management/front-matter.md
@@ -243,7 +243,7 @@ You can add taxonomy terms to the front matter of any these [page kinds](g):
Access taxonomy terms from a template using the [`Params`] or [`GetTerms`] method on a `Page` object. For example:
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ with .GetTerms "tags" }}
@@ -252,7 +252,7 @@ Access taxonomy terms from a template using the [`Params`] or [`GetTerms`] metho
{{ end }}
{{ end }}
-{{< /code >}}
+```
[`Params`]: /methods/page/params/
[`GetTerms`]: /methods/page/getterms/
@@ -330,7 +330,7 @@ If you choose to define cascade values in front matter for a multilingual site,
If your [content format] is [Emacs Org Mode], you may provide front matter using Org Mode keywords. For example:
-{{< code file=content/example.org lang=text >}}
+```text {file="content/example.org"}
#+TITLE: Example
#+DATE: 2024-02-02T04:14:54-08:00
#+DRAFT: false
@@ -340,13 +340,13 @@ If your [content format] is [Emacs Org Mode], you may provide front matter using
#+TAGS: red
#+TAGS: blue
#+WEIGHT: 10
-{{< /code >}}
+```
Note that you can also specify array elements on a single line:
-{{< code file=content/example.org lang=text >}}
+```text {file="content/example.org"}
#+TAGS[]: red blue
-{{< /code >}}
+```
[content format]: /content-management/formats/
[emacs org mode]: https://orgmode.org/
diff --git a/content/en/content-management/mathematics.md b/content/en/content-management/mathematics.md
index 5c9e71bd7..50f33af4e 100644
--- a/content/en/content-management/mathematics.md
+++ b/content/en/content-management/mathematics.md
@@ -91,7 +91,7 @@ inline = [['@', '@']]
Create a partial template to load MathJax or KaTeX. The example below loads MathJax, or you can use KaTeX as described in the [engines](#engines) section.
-{{< code file=layouts/partials/math.html copy=true >}}
+```go-html-template {file="layouts/partials/math.html" copy=true}
-{{< /code >}}
+```
The delimiters above must match the delimiters in your site configuration.
@@ -112,7 +112,7 @@ The delimiters above must match the delimiters in your site configuration.
Conditionally call the partial template from the base template.
-{{< code file=layouts/_default/baseof.html >}}
+```go-html-template {file="layouts/_default/baseof.html"}
...
{{ if .Param "math" }}
@@ -120,7 +120,7 @@ Conditionally call the partial template from the base template.
{{ end }}
...
-{{< /code >}}
+```
The example above loads the partial template if you have set the `math` parameter in front matter to `true`. If you have not set the `math` parameter in front matter, the conditional statement falls back to the `math` parameter in your site configuration.
@@ -128,7 +128,7 @@ The example above loads the partial template if you have set the `math` paramete
Include mathematical equations and expressions in Markdown using LaTeX markup.
-{{< code file=content/math-examples.md copy=true >}}
+```text {file="content/math-examples.md" copy=true}
This is an inline \(a^*=x-b^*\) equation.
These are block equations:
@@ -150,7 +150,7 @@ $$ a^*=x-b^* $$
$$
a^*=x-b^*
$$
-{{< /code >}}
+```
If you set the `math` parameter to `false` in your site configuration, you must set the `math` parameter to `true` in front matter. For example:
@@ -187,7 +187,7 @@ See the [inline delimiters](#inline-delimiters) section for details.
To use KaTeX instead of MathJax, replace the partial template from [Step 2] with this:
-{{< code file=layouts/partials/math.html copy=true >}}
+```go-html-template {file="layouts/partials/math.html" copy=true}
-{{< /code >}}
+```
The delimiters above must match the delimiters in your site configuration.
diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md
index 9a5d1a0e6..745e5917b 100644
--- a/content/en/content-management/multilingual.md
+++ b/content/en/content-management/multilingual.md
@@ -119,7 +119,7 @@ Page Bundle resources follow the same language assignment logic as content files
To create a list of links to translated content, use a template similar to the following:
-{{< code file=layouts/partials/i18nlist.html >}}
+```go-html-template {file="layouts/partials/i18nlist.html"}
{{ if .IsTranslated }}
{{ i18n "translations" }}
@@ -130,7 +130,7 @@ To create a list of links to translated content, use a template similar to the f
{{ end }}
{{ end }}
-{{< /code >}}
+```
The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template. It will not print anything if there are no translations for a given page.
@@ -140,13 +140,13 @@ The above also uses the [`i18n` function][i18func] described in the next section
`.AllTranslations` on a `Page` can be used to list all translations, including the page itself. On the home page it can be used to build a language navigator:
-{{< code file=layouts/partials/allLanguages.html >}}
+```go-html-template {file="layouts/partials/allLanguages.html"}
{{ range $.Site.Home.AllTranslations }}
-{{< /code >}}
+```
## Translation of strings
diff --git a/content/en/content-management/related-content.md b/content/en/content-management/related-content.md
index 6552f7bb1..48fd246c4 100644
--- a/content/en/content-management/related-content.md
+++ b/content/en/content-management/related-content.md
@@ -12,7 +12,7 @@ Hugo uses a set of factors to identify a page's related content based on front m
To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your template:
-{{< code file=layouts/partials/related.html copy=true >}}
+```go-html-template {file="layouts/partials/related.html" copy=true}
{{ with site.RegularPages.Related . | first 5 }}
@@ -21,7 +21,7 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete
{{ end }}
{{ end }}
-{{< /code >}}
+```
The `Related` method takes one argument which may be a `Page` or an options map. The options map has these options:
diff --git a/content/en/content-management/sections.md b/content/en/content-management/sections.md
index 70440bde3..6fbe7aacc 100644
--- a/content/en/content-management/sections.md
+++ b/content/en/content-management/sections.md
@@ -110,7 +110,7 @@ The content file (benefit-1.md) has four ancestors: benefits, product-1, product
For example, use the `.Ancestors` method to render breadcrumb navigation.
-{{< code file=layouts/partials/breadcrumb.html >}}
+```go-html-template {file="layouts/partials/breadcrumb.html"}
-{{< /code >}}
+```
With this CSS:
diff --git a/content/en/content-management/shortcodes.md b/content/en/content-management/shortcodes.md
index 25bb95315..31e36826b 100644
--- a/content/en/content-management/shortcodes.md
+++ b/content/en/content-management/shortcodes.md
@@ -22,17 +22,17 @@ Hugo's embedded shortcodes are pre-defined templates within the application. Ref
Create custom shortcodes to simplify and standardize content creation. For example, the following shortcode template generates an audio player using a [global resource](g):
-{{< code file=layouts/shortcodes/audio.html >}}
+```go-html-template {file="layouts/shortcodes/audio.html"}
{{ with resources.Get (.Get "src") }}
{{ end }}
-{{< /code >}}
+```
Then call the shortcode from within markup:
-{{< code file=content/example.md lang=text >}}
+```text {file="content/example.md"}
{{* audio src=/audio/test.mp3 */>}}
-{{< /code >}}
+```
Learn more about creating shortcodes in the [shortcode templates] section.
@@ -57,14 +57,14 @@ The following example demonstrates an inline shortcode, `date.inline`, that acce
[layout string]: /functions/time/format/#layout-string
-{{< code file=content/example.md lang=text >}}
+```text {file="content/example.md"}
Today is
{{* date.inline ":date_medium" */>}}
{{- now | time.Format (.Get 0) -}}
{{* /date.inline */>}}.
Today is {{* date.inline ":date_full" /*/>}}.
-{{< /code >}}
+```
In the example above, the inline shortcode is executed twice: once upon definition and again when subsequently called. Hugo renders this to:
@@ -196,17 +196,17 @@ With standard notation, Hugo processes the shortcode separately, merging the out
By way of example, with this shortcode template:
-{{< code file=layouts/shortcodes/foo.html >}}
+```go-html-template {file="layouts/shortcodes/foo.html"}
{{ .Inner }}
-{{< /code >}}
+```
And this markdown:
-{{< code file=content/example.md lang=text >}}
+```text {file="content/example.md"}
{{%/* foo */%}} ## Section 1 {{%/* /foo */%}}
{{* foo */>}} ## Section 2 {{* /foo */>}}
-{{< /code >}}
+```
Hugo renders this HTML:
@@ -224,13 +224,13 @@ The shortcode author determines which notation to use. Consult each shortcode's
Shortcodes (excluding [inline](#inline) shortcodes) can be nested, creating parent-child relationships. For example, a gallery shortcode might contain several image shortcodes:
-{{< code file=content/example.md lang=text >}}
+```text {file="content/example.md"}
{{* gallery class="content-gallery" */>}}
{{* image src="/images/a.jpg" */>}}
{{* image src="/images/b.jpg" */>}}
{{* image src="/images/c.jpg" */>}}
{{* /gallery */>}}
-{{< /code >}}
+```
The [shortcode templates][nesting] section provides a detailed explanation and examples.
diff --git a/content/en/content-management/summaries.md b/content/en/content-management/summaries.md
index 894548f46..da61c2c8e 100644
--- a/content/en/content-management/summaries.md
+++ b/content/en/content-management/summaries.md
@@ -20,7 +20,7 @@ Review the [comparison table](#comparison) below to understand the characteristi
Use a `` divider to indicate the end of the summary. Hugo will not render the summary divider itself.
-{{< code file=content/example.md >}}
+```text {file="content/example.md"}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
@@ -31,7 +31,7 @@ This is the first paragraph.
This is the second paragraph.
-{{< /code >}}
+```
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the summary.
@@ -41,7 +41,7 @@ When using the Emacs Org Mode [content format], use a `# more` divider to indica
Use front matter to define a summary independent of content.
-{{< code file=content/example.md >}}
+```text {file="content/example.md"}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
@@ -51,7 +51,7 @@ summary: 'This summary is independent of the content.'
This is the first paragraph.
This is the second paragraph.
-{{< /code >}}
+```
## Automatic summary
@@ -59,7 +59,7 @@ If you do not define the summary manually or in front matter, Hugo automatically
[`summaryLength`]: /configuration/all/#summarylength
-{{< code file=content/example.md >}}
+```text {file="content/example.md"}
+++
title: 'Example'
date: 2024-05-26T09:10:33-07:00
@@ -70,7 +70,7 @@ This is the first paragraph.
This is the second paragraph.
This is the third paragraph.
-{{< /code >}}
+```
For example, with a `summaryLength` of 7, the automatic summary will be:
diff --git a/content/en/content-management/syntax-highlighting.md b/content/en/content-management/syntax-highlighting.md
index 589101785..253add224 100644
--- a/content/en/content-management/syntax-highlighting.md
+++ b/content/en/content-management/syntax-highlighting.md
@@ -19,11 +19,11 @@ Hugo provides several methods to add syntax highlighting to code examples:
In its default configuration, Hugo highlights code examples within fenced code blocks, following this form:
-{{< code file=content/example.md lang=text >}}
+````text {file="content/example.md"}
```LANG [OPTIONS]
CODE
```
-{{< /code >}}
+````
CODE
: The code to highlight.
@@ -39,7 +39,7 @@ OPTIONS
For example, with this Markdown:
-{{< code file=content/example.md lang=text >}}
+````text {file="content/example.md"}
```go {linenos=inline hl_lines=[3,"6-8"] style=emacs}
package main
@@ -51,7 +51,7 @@ func main() {
}
}
```
-{{< /code >}}
+````
Hugo renders this:
@@ -75,13 +75,13 @@ func main() {
When documenting shortcode usage, escape the tag delimiters:
-{{< code file=content/example.md lang=text >}}
+````text {file="content/example.md"}
```text {linenos=inline}
{{*/* shortcode-1 */*/>}}
{{%/*/* shortcode-2 */*/%}}
```
-{{< /code >}}
+````
Hugo renders this to:
diff --git a/content/en/content-management/urls.md b/content/en/content-management/urls.md
index f399bd6cb..8b6ab27d1 100644
--- a/content/en/content-management/urls.md
+++ b/content/en/content-management/urls.md
@@ -236,7 +236,7 @@ public/
The alias from the previous URL to the new URL is a client-side redirect:
-{{< code file=posts/previous-file-name/index.html >}}
+```html {file="posts/previous-file-name/index.html"}
@@ -247,7 +247,7 @@ The alias from the previous URL to the new URL is a client-side redirect:
-{{< /code >}}
+```
Collectively, the elements in the `head` section:
diff --git a/content/en/contribute/documentation.md b/content/en/contribute/documentation.md
index 0421991a4..d38f128cb 100644
--- a/content/en/contribute/documentation.md
+++ b/content/en/contribute/documentation.md
@@ -126,15 +126,21 @@ Other best practices:
- Avoid bold text; use the note shortcode for emphasis.
- Do not put description terms (`dt`) in backticks unless syntactically necessary.
- Do not use Hugo's `ref` or `relref` shortcodes.
-- Prioritize current best practices over multiple options or historical - information.
+- Prioritize current best practices over multiple options or historical information.
- Use short, focused code examples.
- Use [basic english] where possible for a global audience.
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
+## Related content
+
+When available, the "See also" sidebar on this site displays related pages using Hugo's [related content] feature, based on front matter keywords. We ensure keyword accuracy by validating them against `data/keywords.yaml` during the build process. If a keyword is not found, you'll be alerted and must either modify the keyword or update the data file. This validation process helps to refine the related content for better results.
+
+[related content]: /content-management/related-content/
+
## Code examples
-Indent code by two spaces. With examples of template code, ddd spaces around template code action delimiters:
+Indent code by two spaces. With examples of template code, add spaces around the action delimiters:
```go-html-template
{{ if eq $foo $bar }}
@@ -154,6 +160,16 @@ Always specify the language:
```
````
+To include a filename header and copy-to-clipboard button:
+
+````text
+```go-html-template {file="layouts/partials/foo.html" copy=true}
+{{ if eq $foo "bar" }}
+ {{ print "foo is bar" }}
+{{ end }}
+```
+````
+
### Shortcode calls
Use this syntax :
@@ -189,40 +205,10 @@ draft = false
{{* /code-toggle */>}}
```
-### Other code examples
-
-Use the [code shortcode] for code examples that require a file name:
-
-```text
-{{* code file=layouts/_default/single.html */>}}
-{{ range .Site.RegularPages }}
- {{ .LinkTitle }}
-{{ end }}
-{{* /code */>}}
-```
-
## Shortcodes
These shortcodes are commonly used throughout the documentation. Other shortcodes are available for specialized use.
-### code
-
-Use the `code` shortcode for code examples that require a file name. This shortcode takes these arguments:
-
-copy
-: (`bool`) Whether to display a copy-to-clipboard button. Default is `false`.
-
-file
-: (`string`) The file name to display above the rendered code.
-
-lang
-: (`string`) The code language. If you do not provide a `lang` argument, the code language is determined by the file extension. If the file extension is `html`, sets the code language to `go-html-template`. Default is `text`.
-
-```text
-{{* code file=content/something/foo.md lang=text copy=true */>}}
-Some code here
-{{* /code */>}}
-```
### code-toggle
Use the `code-toggle` shortcode to display examples of site configuration, front matter, or data files. This shortcode takes these arguments:
@@ -419,7 +405,6 @@ A project maintainer will review your PR and may request changes. You may delete
[`glossary-term`]: #glossary-term
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[code examples]: #code-examples
-[code shortcode]: #code
[code-toggle shortcode]: #code-toggle
[documentation repository]: https://github.com/gohugoio/hugoDocs/
[fenced code blocks]: https://spec.commonmark.org/0.30/#fenced-code-blocks
diff --git a/content/en/functions/collections/After.md b/content/en/functions/collections/After.md
index e1553f99a..c8a822846 100644
--- a/content/en/functions/collections/After.md
+++ b/content/en/functions/collections/After.md
@@ -38,7 +38,7 @@ You can use `after` in combination with the [`first`] function and Hugo's [power
1. The top row is titled "Featured" and shows only the most recently published article (i.e. by `publishdate` in the content files' front matter).
1. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles.
-{{< code file=layouts/section/articles.html >}}
+```go-html-template {file="layouts/section/articles.html"}
{{ define "main" }}
Featured Article
@@ -61,7 +61,7 @@ You can use `after` in combination with the [`first`] function and Hugo's [power
{{ end }}
{{ end }}
-{{< /code >}}
+```
[`first`]: /functions/collections/first/
[`slice`]: /functions/collections/slice/
diff --git a/content/en/functions/collections/Where.md b/content/en/functions/collections/Where.md
index 4254560eb..05dafe3c9 100644
--- a/content/en/functions/collections/Where.md
+++ b/content/en/functions/collections/Where.md
@@ -214,12 +214,12 @@ With TOML, date values are first-class citizens. TOML has a date data type while
In the TOML example below, note that the event date is not quoted.
-{{< code file=content/events/2024-user-conference.md >}}
+```text {file="content/events/2024-user-conference.md"}
+++
title = '2024 User Conference"
eventDate = 2024-04-01
+++
-{{< /code >}}
+```
To return a collection of future events:
diff --git a/content/en/functions/css/PostCSS.md b/content/en/functions/css/PostCSS.md
index 77432dc57..8741f7330 100644
--- a/content/en/functions/css/PostCSS.md
+++ b/content/en/functions/css/PostCSS.md
@@ -42,13 +42,13 @@ npm i -D postcss postcss-cli autoprefixer
Create a PostCSS configuration file in the root of your project.
-{{< code file=postcss.config.js >}}
+```js {file="postcss.config.js"}
module.exports = {
plugins: [
require('autoprefixer')
]
};
-{{< /code >}}
+```
{{< note >}}
{{% include "/_common/functions/postcss-windows-warning.md" %}}
diff --git a/content/en/functions/css/TailwindCSS.md b/content/en/functions/css/TailwindCSS.md
index 9da079f1d..4c5bbac75 100644
--- a/content/en/functions/css/TailwindCSS.md
+++ b/content/en/functions/css/TailwindCSS.md
@@ -58,10 +58,10 @@ target = "css"
Create a CSS entry file:
-{{< code file=assets/css/main.css copy=true >}}
+```css {file="assets/css/main.css" copy=true}
@import "tailwindcss";
@source "hugo_stats.json";
-{{< /code >}}
+```
Tailwind CSS respects `.gitignore` files. This means that if `hugo_stats.json` is listed in your `.gitignore` file, Tailwind CSS will ignore it. To make `hugo_stats.json` available to Tailwind CSS you must explicitly source it as shown in the example above.
@@ -69,7 +69,7 @@ Tailwind CSS respects `.gitignore` files. This means that if `hugo_stats.json` i
Create a partial template to process the CSS with the Tailwind CSS CLI:
-{{< code file=layouts/partials/css.html copy=true >}}
+```go-html-template {file="layouts/partials/css.html" copy=true}
{{ with (templates.Defer (dict "key" "global")) }}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict
@@ -87,19 +87,19 @@ Create a partial template to process the CSS with the Tailwind CSS CLI:
{{ end }}
{{ end }}
{{ end }}
-{{< /code >}}
+```
### Step 5
Call the partial template from your base template:
-{{< code file=layouts/default/baseof.html >}}
+```go-html-template {file="layouts/default/baseof.html"}
...
{{ partialCached "css.html" . }}
...
-{{< /code >}}
+```
### Step 6
@@ -109,7 +109,7 @@ extension] for Visual Studio Code.
[Tailwind CSS IntelliSense
extension]: https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
-{{< code file=tailwind.config.js copy=true >}}
+```js {file="tailwind.config.js" copy=true}
/*
This file is present to satisfy a requirement of the Tailwind CSS IntelliSense
extension for Visual Studio Code.
@@ -118,7 +118,7 @@ https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
The rest of this file is intentionally empty.
*/
-{{< /code >}}
+```
## Options
diff --git a/content/en/functions/diagrams/Goat.md b/content/en/functions/diagrams/Goat.md
index 483dcb26f..6b7dc0019 100644
--- a/content/en/functions/diagrams/Goat.md
+++ b/content/en/functions/diagrams/Goat.md
@@ -36,7 +36,7 @@ Hugo natively supports [GoAT](https://github.com/bep/goat) diagrams with an [emb
This Markdown:
-````
+````text
```goat
.---. .-. .-. .-. .---.
| A +--->| 1 |<--->| 2 |<--->| 3 |<---+ B |
@@ -68,7 +68,7 @@ To customize rendering, override Hugo's [embedded code block render hook] for Go
By way of example, let's create a code block render hook to render GoAT diagrams as `figure` elements with an optional caption.
-{{< code file=layouts/_default/_markup/render-codeblock-goat.html >}}
+```go-html-template {file="layouts/_default/_markup/render-codeblock-goat.html"}
{{ $caption := or .Attributes.caption "" }}
{{ $class := or .Attributes.class "diagram" }}
{{ $id := or .Attributes.id (printf "diagram-%d" (add 1 .Ordinal)) }}
@@ -81,17 +81,17 @@ By way of example, let's create a code block render hook to render GoAT diagrams
{{ end }}
{{ .Title }}
{{ .Content }}
{{ end }}
-{{< /code >}}
+```
-{{< code file=layouts/_default/list.html >}}
+```go-html-template {file="layouts/_default/list.html"}
{{ define "main" }}
{{ .Title }}
{{ .Content }}
@@ -48,6 +48,6 @@ The typical use is to define a set of root templates that are then customized by
{{ .LinkTitle }}
{{ end }}
{{ end }}
-{{< /code >}}
+```
{{% include "/_common/functions/go-template/text-template.md" %}}
diff --git a/content/en/functions/go-template/return.md b/content/en/functions/go-template/return.md
index 68c9baeed..8d43d2d31 100644
--- a/content/en/functions/go-template/return.md
+++ b/content/en/functions/go-template/return.md
@@ -24,13 +24,13 @@ Unlike `return` statements in other languages, Hugo executes the first occurrenc
By way of example, let's create a partial template that _renders_ HTML, describing whether the given number is odd or even:
-{{< code file=layouts/partials/odd-or-even.html >}}
+```go-html-template {file="layouts/partials/odd-or-even.html"}
{{ if math.ModBool . 2 }}
{{ end }}
-{{< /code >}}
+```
Then hide the QR code with CSS unless printing the page:
diff --git a/content/en/functions/js/Babel.md b/content/en/functions/js/Babel.md
index 69bd21636..d0007aaa0 100644
--- a/content/en/functions/js/Babel.md
+++ b/content/en/functions/js/Babel.md
@@ -90,7 +90,6 @@ noComments
sourceMap
: (`string`) Whether to generate source maps, one of `external`, `inline`, or `none`. Default is `none`.
-
verbose
: (`bool`) Whether to enable verbose logging. Default is `false`
diff --git a/content/en/functions/partials/IncludeCached.md b/content/en/functions/partials/IncludeCached.md
index 21482cd3e..01dac0b99 100644
--- a/content/en/functions/partials/IncludeCached.md
+++ b/content/en/functions/partials/IncludeCached.md
@@ -29,9 +29,9 @@ Here is the simplest usage:
Pass additional arguments to `partialCached` to create variants of the cached partial. For example, if you have a complex partial that should be identical when rendered for pages within the same section, use a variant based on section so that the partial is only rendered once per section:
-{{< code file=partial-cached-example.html >}}
+```go-html-template {file="layouts/_default/baseof.html"}
{{ partialCached "footer.html" . .Section }}
-{{< /code >}}
+```
Pass additional arguments, of any data type, as needed to create unique variants:
diff --git a/content/en/functions/resources/ExecuteAsTemplate.md b/content/en/functions/resources/ExecuteAsTemplate.md
index 0c90a03b3..0e7d244b2 100644
--- a/content/en/functions/resources/ExecuteAsTemplate.md
+++ b/content/en/functions/resources/ExecuteAsTemplate.md
@@ -21,12 +21,13 @@ Hugo publishes the resource to the target path when you call its [`Publish`], [`
Let's say you have a CSS file that you wish to populate with values from your site configuration:
-{{< code file=assets/css/template.css lang=go-html-template >}}
+
+```go-html-template {file="assets/css/template.css"}
body {
background-color: {{ site.Params.style.bg_color }};
color: {{ site.Params.style.text_color }};
}
-{{< /code >}}
+```
And your site configuration contains:
@@ -54,9 +55,10 @@ The example above:
The result is:
-{{< code file=public/css/main.css >}}
+
+```css {file="public/css/main.css"}
body {
background-color: #fefefe;
color: #222;
}
-{{< /code >}}
+```
diff --git a/content/en/functions/resources/PostProcess.md b/content/en/functions/resources/PostProcess.md
index 25be1274d..c331f76b2 100644
--- a/content/en/functions/resources/PostProcess.md
+++ b/content/en/functions/resources/PostProcess.md
@@ -58,7 +58,7 @@ See the [configure build] documentation for details and options.
Step 4
: Create a PostCSS configuration file in the root of your project.
-{{< code file="postcss.config.js" copy=true >}}
+```js {file="postcss.config.js" copy=true}
const autoprefixer = require('autoprefixer');
const purgeCSSPlugin = require('@fullhuman/postcss-purgecss').default;
@@ -82,7 +82,7 @@ module.exports = {
autoprefixer,
]
};
-{{< /code >}}
+```
{{< note >}}
{{% include "/_common/functions/postcss-windows-warning.md" %}}
diff --git a/content/en/functions/transform/PortableText.md b/content/en/functions/transform/PortableText.md
index db2264b1b..f501f6059 100644
--- a/content/en/functions/transform/PortableText.md
+++ b/content/en/functions/transform/PortableText.md
@@ -27,7 +27,7 @@ Since the Portable Text gets converted to Markdown before it gets passed to Hugo
### Content Adapter
-{{< code file=content/_content.gotmpl copy=true >}}
+```go-html-template {file="content/_content.gotmpl" copy=true}
{{ $projectID := "mysanityprojectid" }}
{{ $useCached := true }}
{{ $api := "api" }}
@@ -91,14 +91,13 @@ Since the Portable Text gets converted to Markdown before it gets passed to Hugo
}}
{{ $.AddPage $page }}
{{ end }}
-{{< /code >}}
-
+```
### Sanity setup
Below outlines a suitable Sanity studio setup for the above example.
-{{< code file=sanity.config.ts copy=true >}}
+```ts {file="sanity.config.ts" copy=true}
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {visionTool} from '@sanity/vision'
@@ -106,7 +105,6 @@ import {schemaTypes} from './schemaTypes'
import {media} from 'sanity-plugin-media'
import {codeInput} from '@sanity/code-input'
-
export default defineConfig({
name: 'default',
title: 'my-sanity-project',
@@ -120,12 +118,11 @@ export default defineConfig({
types: schemaTypes,
},
})
-
-{{< /code >}}
+```
Type/schema definition:
-{{< code file=schemaTypes/postType.ts copy=true >}}
+```ts {file="schemaTypes/postType.ts" copy=true}
import {defineField, defineType} from 'sanity'
export const postType = defineType({
@@ -180,7 +177,7 @@ export const postType = defineType({
}),
],
})
-{{< /code >}}
+```
Note that the above requires some additional plugins to be installed:
@@ -188,11 +185,11 @@ Note that the above requires some additional plugins to be installed:
npm i sanity-plugin-media @sanity/code-input
```
-{{< code file=schemaTypes/index.ts copy=true >}}
+```ts {file="schemaTypes/index.ts" copy=true}
import {postType} from './postType'
export const schemaTypes = [postType]
-{{< /code >}}
+```
## Server setup
diff --git a/content/en/functions/transform/ToMath.md b/content/en/functions/transform/ToMath.md
index 6f3312e94..0661a7ec9 100644
--- a/content/en/functions/transform/ToMath.md
+++ b/content/en/functions/transform/ToMath.md
@@ -117,7 +117,7 @@ Create a [passthrough render hook] to capture and render the LaTeX markup.
[passthrough render hook]: /render-hooks/passthrough/
-{{< code file=layouts/_default/_markup/render-passthrough.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-passthrough.html" copy=true}
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
{{- with .Err }}
@@ -127,20 +127,20 @@ Create a [passthrough render hook] to capture and render the LaTeX markup.
{{- $.Page.Store.Set "hasMath" true }}
{{- end }}
{{- end -}}
-{{< /code >}}
+```
### Step 3
In your base template, conditionally include the KaTeX CSS within the head element.
-{{< code file=layouts/_default/baseof.html copy=true >}}
+```go-html-template {file="layouts/_default/baseof.html" copy=true}
{{ $noop := .WordCount }}
{{ if .Page.Store.Get "hasMath" }}
{{ end }}
-{{< /code >}}
+```
In the above, note the use of a [noop](g) statement to force content rendering before we check the value of `hasMath` with the `Store.Get` method.
@@ -148,7 +148,7 @@ In the above, note the use of a [noop](g) statement to force content rendering b
Add some mathematical markup to your content, then test.
-{{< code file=content/example.md >}}
+```text {file="content/example.md"}
This is an inline \(a^*=x-b^*\) equation.
These are block equations:
@@ -156,7 +156,7 @@ These are block equations:
\[a^*=x-b^*\]
$$a^*=x-b^*$$
-{{< /code >}}
+```
## Chemistry
diff --git a/content/en/functions/transform/XMLEscape.md b/content/en/functions/transform/XMLEscape.md
index 234dec6bb..11a5d0228 100644
--- a/content/en/functions/transform/XMLEscape.md
+++ b/content/en/functions/transform/XMLEscape.md
@@ -32,9 +32,9 @@ For example:
When using `transform.XMLEscape` in a template rendered by Go's [html/template] package, declare the string to be safe HTML to avoid double escaping. For example, in an RSS template:
-{{< code file=layouts/_default/rss.xml >}}
+```xml {file="layouts/_default/rss.xml"}
{{ range .Site.Menus.main }}
-{{< /code >}}
+```
Hugo render this HTML:
@@ -96,13 +96,13 @@ In the above note that the `href` attribute of the second `anchor` element is bl
With this template code:
-{{< code file=layouts/partials/menu.html >}}
+```go-html-template {file="layouts/partials/menu.html"}
{{ range .Site.Menus.main }}
-{{< /code >}}
+```
Hugo renders this HTML:
diff --git a/content/en/methods/page/Description.md b/content/en/methods/page/Description.md
index f5907116f..5287aa699 100644
--- a/content/en/methods/page/Description.md
+++ b/content/en/methods/page/Description.md
@@ -16,12 +16,12 @@ title = 'How to make spicy tuna hand rolls'
description = 'Instructions for making spicy tuna hand rolls.'
{{< /code-toggle >}}
-{{< code file=layouts/baseof.html >}}
+```go-html-template {file="layouts/_default/baseof.html"}
...
...
-{{< /code >}}
+```
[content summary]: /content-management/summaries/
diff --git a/content/en/methods/page/GetPage.md b/content/en/methods/page/GetPage.md
index 766e86e23..02f6888e0 100644
--- a/content/en/methods/page/GetPage.md
+++ b/content/en/methods/page/GetPage.md
@@ -37,7 +37,7 @@ content/
The examples below depict the result of rendering works/paintings/the-mona-lisa.md:
-{{< code file=layouts/works/single.html >}}
+```go-html-template {file="layouts/works/single.html"}
{{ with .GetPage "starry-night" }}
{{ .Title }} → Starry Night
{{ end }}
@@ -61,4 +61,4 @@ The examples below depict the result of rendering works/paintings/the-mona-lisa.
{{ with .GetPage "/works/sculptures/david" }}
{{ .Title }} → David
{{ end }}
-{{< /code >}}
+```
diff --git a/content/en/methods/page/HasShortcode.md b/content/en/methods/page/HasShortcode.md
index 3b1c3de10..6ddf69df4 100644
--- a/content/en/methods/page/HasShortcode.md
+++ b/content/en/methods/page/HasShortcode.md
@@ -14,7 +14,7 @@ By example, let's use [Plotly] to render a chart:
[Plotly]: https://plotly.com/javascript/
-{{< code file=contents/example.md lang=text >}}
+```text {file="content/example.md"}
{{* plotly */>}}
{
"data": [
@@ -26,21 +26,21 @@ By example, let's use [Plotly] to render a chart:
],
}
{{* /plotly */>}}
-{{< /code >}}
+```
The shortcode is simple:
-{{< code file=layouts/shortcodes/plotly.html >}}
+```go-html-template {file="layouts/shortcodes/plotly.html"}
{{ $id := printf "plotly-%02d" .Ordinal }}
-{{< /code >}}
+```
Now we can selectively load the required JavaScript on pages that call the "plotly" shortcode:
-{{< code file=layouts/baseof.html >}}
+```go-html-template {file="layouts/_default/baseof.html"}
...
{{ if .HasShortcode "plotly" }}
@@ -48,4 +48,4 @@ Now we can selectively load the required JavaScript on pages that call the "plot
{{ end }}
...
-{{< /code >}}
+```
diff --git a/content/en/methods/page/InSection.md b/content/en/methods/page/InSection.md
index c6feeb8ab..4b4cca1ad 100644
--- a/content/en/methods/page/InSection.md
+++ b/content/en/methods/page/InSection.md
@@ -13,8 +13,6 @@ params:
The `InSection` method on a `Page` object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling.
-
-
With this content structure:
```text
diff --git a/content/en/methods/page/Page.md b/content/en/methods/page/Page.md
index bbbf240a6..bdd7b5962 100644
--- a/content/en/methods/page/Page.md
+++ b/content/en/methods/page/Page.md
@@ -12,21 +12,21 @@ params:
This is a convenience method, useful within partial templates that are called from both [shortcodes](g) and page templates.
-{{< code file=layouts/shortcodes/foo.html >}}
+```go-html-template {file="layouts/shortcodes/foo.html"}
{{ partial "my-partial.html" . }}
-{{< /code >}}
+```
When the shortcode calls the partial, it passes the current [context](g) (the dot). The context includes identifiers such as `Page`, `Params`, `Inner`, and `Name`.
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ partial "my-partial.html" . }}
-{{< /code >}}
+```
When the page template calls the partial, it also passes the current context (the dot). But in this case, the dot _is_ the `Page` object.
-{{< code file=layouts/partials/my-partial.html >}}
+```go-html-template {file="layouts/partials/my-partial.html"}
The page title is: {{ .Page.Title }}
-{{< /code >}}
+```
To handle both scenarios, the partial template must be able to access the `Page` object with `Page.Page`.
diff --git a/content/en/methods/page/Paginate.md b/content/en/methods/page/Paginate.md
index a43b2cb3d..fdf67ef2e 100644
--- a/content/en/methods/page/Paginate.md
+++ b/content/en/methods/page/Paginate.md
@@ -28,14 +28,14 @@ You can invoke pagination on the [home template], [section templates], [taxonomy
[taxonomy templates]: /templates/types/#taxonomy
[term templates]: /templates/types/#term
-{{< code file=layouts/_default/list.html >}}
+```go-html-template {file="layouts/_default/list.html"}
{{ $pages := where .Site.RegularPages "Section" "articles" }}
{{ $pages = $pages.ByTitle }}
{{ range (.Paginate $pages 7).Pages }}
{{ .Title }}
{{ end }}
{{ template "_internal/pagination.html" . }}
-{{< /code >}}
+```
In the example above, we:
diff --git a/content/en/methods/page/Paginator.md b/content/en/methods/page/Paginator.md
index 8e39a9981..a97f6461c 100644
--- a/content/en/methods/page/Paginator.md
+++ b/content/en/methods/page/Paginator.md
@@ -22,12 +22,12 @@ You can invoke pagination on the [home template], [section templates], [taxonomy
[taxonomy templates]: /templates/types/#taxonomy
[term templates]: /templates/types/#term
-{{< code file=layouts/_default/list.html >}}
+```go-html-template {file="layouts/_default/list.html"}
{{ range .Paginator.Pages }}
{{ .LinkTitle }}
{{ end }}
{{ template "_internal/pagination.html" . }}
-{{< /code >}}
+```
In the example above, the embedded pagination template creates navigation links between pagers.
diff --git a/content/en/methods/page/RenderShortcodes.md b/content/en/methods/page/RenderShortcodes.md
index c91e9ef8d..d124606f0 100644
--- a/content/en/methods/page/RenderShortcodes.md
+++ b/content/en/methods/page/RenderShortcodes.md
@@ -15,7 +15,7 @@ Use this method in shortcode templates to compose a page from multiple content f
For example:
-{{< code file=layouts/shortcodes/include.html >}}
+```go-html-template {file="layouts/shortcodes/include.html" copy=true}
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}
@@ -25,15 +25,15 @@ For example:
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the logical path of the file to include. See %s" .Name .Position }}
{{ end }}
-{{< /code >}}
+```
Then call the shortcode in your Markdown:
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
{{%/* include "/snippets/services" */%}}
{{%/* include "/snippets/values" */%}}
{{%/* include "/snippets/leadership" */%}}
-{{< /code >}}
+```
Each of the included Markdown files can contain calls to other shortcodes.
@@ -50,7 +50,7 @@ Use the latter for the "include" shortcode described above.
To understand what is returned by the `RenderShortcodes` method, consider this content file
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
+++
title = 'About'
date = 2023-10-07T12:28:33-07:00
@@ -59,7 +59,7 @@ date = 2023-10-07T12:28:33-07:00
{{* ref "privacy" */>}}
An *emphasized* word.
-{{< /code >}}
+```
With this template code:
diff --git a/content/en/methods/page/Sitemap.md b/content/en/methods/page/Sitemap.md
index 772460ab3..80ad0b3b6 100644
--- a/content/en/methods/page/Sitemap.md
+++ b/content/en/methods/page/Sitemap.md
@@ -59,7 +59,7 @@ changeFreq = 'hourly'
And this simplistic sitemap template:
-{{< code file=layouts/_default/sitemap.xml >}}
+```xml {file="layouts/_default/sitemap.xml"}
{{ printf "" | safeHTML }}
@@ -24,11 +24,11 @@ The argument passed to the `Related` method may be a `Page` or an options map. F
{{ end }}
{{ end }}
-{{< /code >}}
+```
To pass an options map:
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ $opts := dict
"document" .
"indices" (slice "tags" "keywords")
@@ -41,7 +41,7 @@ To pass an options map:
{{ end }}
{{ end }}
-{{< /code >}}
+```
## Options
diff --git a/content/en/methods/resource/Content.md b/content/en/methods/resource/Content.md
index d30b6b1b3..f2a0f235a 100644
--- a/content/en/methods/resource/Content.md
+++ b/content/en/methods/resource/Content.md
@@ -16,9 +16,9 @@ The `Content` method on a `Resource` object returns `template.HTML` when the res
[resource type]: /methods/resource/resourcetype/
-{{< code file=assets/quotations/kipling.txt >}}
+```text {file="assets/quotations/kipling.txt"}
He travels the fastest who travels alone.
-{{< /code >}}
+```
To get the content:
diff --git a/content/en/methods/resource/ResourceType.md b/content/en/methods/resource/ResourceType.md
index 56e60856f..9ced93396 100644
--- a/content/en/methods/resource/ResourceType.md
+++ b/content/en/methods/resource/ResourceType.md
@@ -37,8 +37,8 @@ content/
With the structure above, we can range through page resources of type `page` to build content:
-{{< code file=layouts/lessons/single.html >}}
+```go-html-template {file="layouts/lessons/single.html"}
{{ range .Resources.ByType "page" }}
{{ .Content }}
{{ end }}
-{{< /code >}}
+```
diff --git a/content/en/methods/shortcode/Get.md b/content/en/methods/shortcode/Get.md
index 6e5297bf1..7bdecb78f 100644
--- a/content/en/methods/shortcode/Get.md
+++ b/content/en/methods/shortcode/Get.md
@@ -19,29 +19,29 @@ Some shortcodes support positional arguments, some support named arguments, and
This shortcode call uses positional arguments:
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
{{* myshortcode "Hello" "world" */>}}
-{{< /code >}}
+```
To retrieve arguments by position:
-{{< code file=layouts/shortcodes/myshortcode.html >}}
+```go-html-template {file="layouts/shortcodes/myshortcode.html"}
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
-{{< /code >}}
+```
## Named arguments
This shortcode call uses named arguments:
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
{{* myshortcode greeting="Hello" firstName="world" */>}}
-{{< /code >}}
+```
To retrieve arguments by name:
-{{< code file=layouts/shortcodes/myshortcode.html >}}
+```go-html-template {file="layouts/shortcodes/myshortcode.html"}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.
-{{< /code >}}
+```
{{< note >}}
Argument names are case-sensitive.
diff --git a/content/en/methods/shortcode/Inner.md b/content/en/methods/shortcode/Inner.md
index 4f34c2f2e..8df179589 100644
--- a/content/en/methods/shortcode/Inner.md
+++ b/content/en/methods/shortcode/Inner.md
@@ -11,15 +11,15 @@ params:
This content:
-{{< code file=content/services.md lang=text >}}
+```text {file="content/services.md"}
{{* card title="Product Design" */>}}
We design the **best** widgets in the world.
{{* /card */>}}
-{{< /code >}}
+```
With this shortcode:
-{{< code file=layouts/shortcodes/card.html >}}
+```go-html-template {file="layouts/shortcodes/card.html"}
-{{< /code >}}
+```
diff --git a/content/en/methods/shortcode/Params.md b/content/en/methods/shortcode/Params.md
index e8347e710..f001e737f 100644
--- a/content/en/methods/shortcode/Params.md
+++ b/content/en/methods/shortcode/Params.md
@@ -11,22 +11,22 @@ params:
When you call a shortcode using positional arguments, the `Params` method returns a slice.
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
{{* myshortcode "Hello" "world" */>}}
-{{< /code >}}
+```
-{{< code file=layouts/shortcodes/myshortcode.html >}}
+```go-html-template {file="layouts/shortcodes/myshortcode.html"}
{{ index .Params 0 }} → Hello
{{ index .Params 1 }} → world
-{{< /code >}}
+```
When you call a shortcode using named arguments, the `Params` method returns a map.
-{{< code file=content/about.md lang=text >}}
+```text {file="content/about.md"}
{{* myshortcode greeting="Hello" name="world" */>}}
-{{< /code >}}
+```
-{{< code file=layouts/shortcodes/myshortcode.html >}}
+```go-html-template {file="layouts/shortcodes/myshortcode.html"}
{{ .Params.greeting }} → Hello
{{ .Params.name }} → world
-{{< /code >}}
+```
diff --git a/content/en/methods/shortcode/Parent.md b/content/en/methods/shortcode/Parent.md
index d18bc8139..69533e2bc 100644
--- a/content/en/methods/shortcode/Parent.md
+++ b/content/en/methods/shortcode/Parent.md
@@ -14,19 +14,19 @@ This is useful for inheritance of common shortcode arguments from the root.
In this contrived example, the "greeting" shortcode is the parent, and the "now" shortcode is child.
-{{< code file=content/welcome.md lang=text >}}
+```text {file="content/welcome.md"}
{{* greeting dateFormat="Jan 2, 2006" */>}}
Welcome. Today is {{* now */>}}.
{{* /greeting */>}}
-{{< /code >}}
+```
-{{< code file=layouts/shortcodes/greeting.html >}}
+```go-html-template {file="layouts/shortcodes/greeting.html"}
{{ .Text }}
-{{< /code >}}
+```
To render a blockquote as an HTML `figure` element with an optional citation and caption:
-{{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-blockquote.html" copy=true}
{{ .Text }}
@@ -77,7 +77,7 @@ To render a blockquote as an HTML `figure` element with an optional citation and
{{ end }}
{{- .Inner | htmlEscape | safeHTML }}
{{ .Page.Store.Set "hasMermaid" true }}
-{{< /code >}}
+```
Then include this snippet at the bottom of the your base template:
-{{< code file=layouts/_default/baseof.html copy=true >}}
+```go-html-template {file="layouts/_default/baseof.html" copy=true}
{{ if .Store.Get "hasMermaid" }}
{{ end }}
-{{< /code >}}
+```
See the [diagrams] page for details.
diff --git a/content/en/render-hooks/headings.md b/content/en/render-hooks/headings.md
index f4ded9b70..89868d478 100755
--- a/content/en/render-hooks/headings.md
+++ b/content/en/render-hooks/headings.md
@@ -46,19 +46,19 @@ In its default configuration, Hugo renders Markdown headings according to the [C
[CommonMark specification]: https://spec.commonmark.org/current/
-{{< code file=layouts/_default/_markup/render-heading.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-heading.html" copy=true}
{{- /* chomp trailing newline */ -}}
-{{< /code >}}
+```
To render standalone images within `figure` elements:
-{{< code file=layouts/_default/_markup/render-image.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-image.html" copy=true}
{{- if .IsBlock -}}
{{- end -}}
-{{< /code >}}
+```
Note that the above requires the following site configuration:
diff --git a/content/en/render-hooks/links.md b/content/en/render-hooks/links.md
index cd7e043df..63fcae567 100755
--- a/content/en/render-hooks/links.md
+++ b/content/en/render-hooks/links.md
@@ -53,18 +53,18 @@ In its default configuration, Hugo renders Markdown links according to the [Comm
[CommonMark specification]: https://spec.commonmark.org/current/
-{{< code file=layouts/_default/_markup/render-link.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-link.html" copy=true}
{{- with .Text }}{{ . }}{{ end -}}
{{- /* chomp trailing newline */ -}}
-{{< /code >}}
+```
To include a `rel` attribute set to `external` for external links:
-{{< code file=layouts/_default/_markup/render-link.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-link.html" copy=true}
{{- $u := urls.Parse .Destination -}}
{{- /* chomp trailing newline */ -}}
-{{< /code >}}
+```
## Default
diff --git a/content/en/render-hooks/passthrough.md b/content/en/render-hooks/passthrough.md
index bfbf4d5fb..5e73a65b5 100755
--- a/content/en/render-hooks/passthrough.md
+++ b/content/en/render-hooks/passthrough.md
@@ -17,7 +17,7 @@ Hugo uses [Goldmark] to render Markdown to HTML. Goldmark supports custom extens
Depending on your choice of delimiters, Hugo will classify a passthrough element as either _block_ or _inline_. Consider this contrived example:
-{{< code file=content/sample.md >}}
+```text {file="content/example.md"}
This is a
\[block\]
@@ -25,7 +25,7 @@ This is a
passthrough element with opening and closing block delimiters.
This is an \(inline\) passthrough element with opening and closing inline delimiters.
-{{< /code >}}
+```
Update your site configuration to enable the Passthrough extension and define opening and closing delimiters for each passthrough element type, either `block` or `inline`. For example:
@@ -86,7 +86,7 @@ Instead of client-side JavaScript rendering of mathematical markup using MathJax
[`transform.ToMath`]: /functions/transform/tomath/
-{{< code file=layouts/_default/_markup/render-passthrough.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-passthrough.html" copy=true}
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
{{- with .Err }}
@@ -96,18 +96,18 @@ Instead of client-side JavaScript rendering of mathematical markup using MathJax
{{- $.Page.Store.Set "hasMath" true }}
{{- end }}
{{- end -}}
-{{< /code >}}
+```
Then, in your base template, conditionally include the KaTeX CSS within the head element:
-{{< code file=layouts/_default/baseof.html copy=true >}}
+```go-html-template {file="layouts/_default/baseof.html" copy=true}
{{ $noop := .WordCount }}
{{ if .Page.Store.Get "hasMath" }}
{{ end }}
-{{< /code >}}
+```
In the above, note the use of a [noop](g) statement to force content rendering before we check the value of `hasMath` with the `Store.Get` method.
diff --git a/content/en/render-hooks/tables.md b/content/en/render-hooks/tables.md
index eeda80692..c7671aff4 100755
--- a/content/en/render-hooks/tables.md
+++ b/content/en/render-hooks/tables.md
@@ -57,7 +57,7 @@ In its default configuration, Hugo renders Markdown tables according to the [Git
[GitHub Flavored Markdown specification]: https://github.github.com/gfm/#tables-extension-
-{{< code file=layouts/_default/_markup/render-table.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-table.html" copy=true}
-{{< /code >}}
+```
{{% include "/_common/render-hooks/pageinner.md" %}}
diff --git a/content/en/shortcodes/highlight.md b/content/en/shortcodes/highlight.md
index 74d8e7d65..f4e133ad7 100755
--- a/content/en/shortcodes/highlight.md
+++ b/content/en/shortcodes/highlight.md
@@ -89,12 +89,12 @@ This is some {{< highlight go "hl_inline=true, noClasses=true" >}}fmt.Println("i
Given the verbosity of the example above, if you need to frequently highlight inline code snippets, create your own shortcode using a shorter name with preset options.
-{{< code file=layouts/shortcodes/hl.html >}}
+```go-html-template {file="layouts/shortcodes/hl.html"}
{{ $code := .Inner | strings.TrimSpace }}
{{ $lang := or (.Get 0) "go" }}
{{ $opts := dict "hl_inline" true "noClasses" true }}
{{ transform.Highlight $code $lang $opts }}
-{{< /code >}}
+```
```text
This is some {{* hl */>}}fmt.Println("inline"){{* /hl */>}} code.
diff --git a/content/en/shortcodes/param.md b/content/en/shortcodes/param.md
index 77b8f7711..0caa33411 100755
--- a/content/en/shortcodes/param.md
+++ b/content/en/shortcodes/param.md
@@ -13,7 +13,7 @@ To override Hugo's embedded `param` shortcode, copy the [source code] to a file
The `param` shortcode renders a parameter from front matter, falling back to a site parameter of the same name. The shortcode throws an error if the parameter does not exist.
-{{< code file=example.md >}}
+```text {file="content/example.md"}
---
title: Example
date: 2025-01-15T23:29:46-08:00
@@ -23,7 +23,7 @@ params:
---
We found a {{%/* param "color" */%}} shirt.
-{{< /code >}}
+```
Hugo renders this to:
diff --git a/content/en/shortcodes/ref.md b/content/en/shortcodes/ref.md
index de915a5ce..63ba78692 100755
--- a/content/en/shortcodes/ref.md
+++ b/content/en/shortcodes/ref.md
@@ -60,9 +60,6 @@ Rendered:
Link D
```
-
-
-
## Error handling
{{% include "_common/ref-and-relref-error-handling.md" %}}
diff --git a/content/en/templates/404.md b/content/en/templates/404.md
index 7162378c4..1a1a3c146 100644
--- a/content/en/templates/404.md
+++ b/content/en/templates/404.md
@@ -9,7 +9,7 @@ weight: 190
To render a 404 error page in the root of your site, create a 404 template in the root of the `layouts` directory. For example:
-{{< code file=layouts/404.html >}}
+```go-html-template {file="layouts/404.html"}
{{ define "main" }}
404 Not Found
{{ . }}
{{ end }} -{{< /code >}} +``` In the example above, the context changes as we `range` through the [slice](g) of values. In the first iteration the context is "foo", and in the second iteration the context is "bar". Inside of the `with` block the context is "baz". Hugo renders the above to: @@ -85,11 +85,11 @@ In the example above, the context changes as we `range` through the [slice](g) o Within a `range` or `with` block you can access the context passed into the template by prepending a dollar sign (`$`) to the dot: -{{< code file=layouts/_default/single.html >}} +```go-html-template {file="layouts/_default/single.html"} {{ with "foo" }}{{ $.Title }} - {{ . }}
{{ end }} -{{< /code >}} +``` Hugo renders this to: @@ -107,12 +107,12 @@ In the examples above the paired opening and closing braces represent the beginn A template action may contain literal values ([boolean](g), [string](g), [integer](g), and [float](g)), variables, functions, and methods. -{{< code file=layouts/_default/single.html >}} +```go-html-template {file="layouts/_default/single.html"} {{ $convertToLower := true }} {{ if $convertToLower }}Affiliation: {{ .Params.affiliation }}
@@ -102,6 +102,6 @@ Then create a term template specific to the "authors" taxonomy:Copyright {{ now.Year }}. All rights reserved.
-{{< /code >}} +``` Learn more about [partial templates](/templates/partial/). @@ -197,7 +197,7 @@ A content view template is similar to a partial template, invoked by calling the For example, the home template below inherits the site's shell from the base template, and renders a card component for each page within the "articles" section of your site. -{{< code file=layouts/_default/home.html >}} +```go-html-template {file="layouts/_default/home.html"} {{ define "main" }} {{ .Content }}{{ $inner }}
-
- {{ end }}
- {{ end }}
-