Cleanup action delimiters

This commit is contained in:
Joe Mooring authored and Joe Mooring committed 2023-04-03 11:50:31 -07:00
1 parent cc96070f06
commit 7bee3e4c14
33 files changed
+157 -157

No files matched your search

@@ -344,7 +344,7 @@ The function will read `.Count` from `.ReadingTime` and evaluate whether the num
{{< code-toggle file="i18n/en-US" >}} {{< code-toggle file="i18n/en-US" >}}
[readingTime] [readingTime]
one = "One minute to read" one = "One minute to read"
other = "{{.Count }} minutes to read" other = "{{ .Count }} minutes to read"
{{< /code-toggle >}} {{< /code-toggle >}}
Assuming `.ReadingTime.Count` in the context has value is 525600. The result will be: Assuming `.ReadingTime.Count` in the context has value is 525600. The result will be:
+1 -1
View File
@@ -185,7 +185,7 @@ This shortcode will convert the source code provided into syntax-highlighted HTM
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
{{ range .Pages }} {{ range .Pages }}
{{ .Render "summary"}} {{ .Render "summary" }}
{{ end }} {{ end }}
</div> </div>
</section> </section>
+4 -4
View File
@@ -14,7 +14,7 @@ aliases: [/extras/toc/]
{{% note "TOC Heading Levels are Fixed" %}} {{% note "TOC Heading Levels are Fixed" %}}
Previously, there was no out-of-the-box way to specify which heading levels you want the TOC to render. [See the related GitHub discussion (#1778)](https://github.com/gohugoio/hugo/issues/1778). As such, the resulting `<nav id="TableOfContents"><ul></ul></nav>` was going to start at `<h1>` when pulling from `{{.Content }}`. Previously, there was no out-of-the-box way to specify which heading levels you want the TOC to render. [See the related GitHub discussion (#1778)](https://github.com/gohugoio/hugo/issues/1778). As such, the resulting `<nav id="TableOfContents"><ul></ul></nav>` was going to start at `<h1>` when pulling from `{{ .Content }}`.
Hugo [v0.60.0](https://github.com/gohugoio/hugo/releases/tag/v0.60.0) made a switch to [Goldmark](https://github.com/yuin/goldmark/) as the default library for Markdown which has improved and configurable implementation of TOC. Take a look at [how to configure TOC](/getting-started/configuration-markup/#table-of-contents) for Goldmark renderer. Hugo [v0.60.0](https://github.com/gohugoio/hugo/releases/tag/v0.60.0) made a switch to [Goldmark](https://github.com/yuin/goldmark/) as the default library for Markdown which has improved and configurable implementation of TOC. Take a look at [how to configure TOC](/getting-started/configuration-markup/#table-of-contents) for Goldmark renderer.
@@ -72,15 +72,15 @@ The following is a [partial template][partials] that adds slightly more logic fo
{{ if and (gt .WordCount 400 ) (.Params.toc) }} {{ if and (gt .WordCount 400 ) (.Params.toc) }}
<aside> <aside>
<header> <header>
<h2>{{.Title }}</h2> <h2>{{ .Title }}</h2>
</header> </header>
{{.TableOfContents }} {{ .TableOfContents }}
</aside> </aside>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
{{% note %}} {{% note %}}
With the preceding example, even pages with > 400 words *and* `toc` not set to `false` will not render a table of contents if there are no headings in the page for the `{{.TableOfContents }}` variable to pull from. With the preceding example, even pages with > 400 words *and* `toc` not set to `false` will not render a table of contents if there are no headings in the page for the `{{ .TableOfContents }}` variable to pull from.
{{% /note %}} {{% /note %}}
## Usage with AsciiDoc ## Usage with AsciiDoc
+9 -9
View File
@@ -72,7 +72,7 @@ Here is a review of the front matter fields automatically generated for you usin
`relatedfuncs` `relatedfuncs`
: other [templating functions] you feel are related to your new function to help fellow Hugo users. : other [templating functions] you feel are related to your new function to help fellow Hugo users.
`{{.Content }}` `{{ .Content }}`
: an extended description of the new function; examples are not only welcomed but encouraged. : an extended description of the new function; examples are not only welcomed but encouraged.
In the body of your function, expand the short description used in the front matter. Include as many examples as possible, and leverage the Hugo docs [`code` shortcode](#add-code-blocks). In the body of your function, expand the short description used in the front matter. Include as many examples as possible, and leverage the Hugo docs [`code` shortcode](#add-code-blocks).
@@ -136,15 +136,15 @@ This example HTML code block tells Hugo users the following:
<main> <main>
<article> <article>
<header> <header>
<h1>{{.Title }}</h1> <h1>{{ .Title }}</h1>
{{ with .Params.subtitle }} {{ with .Params.subtitle }}
<span>{{.}}</span> <span>{{ . }}</span>
</header> </header>
<div> <div>
{{.Content }} {{ .Content }}
</div> </div>
<aside> <aside>
{{.TableOfContents }} {{ .TableOfContents }}
</aside> </aside>
</article> </article>
</main> </main>
@@ -161,15 +161,15 @@ The output of this example will render to the Hugo docs as follows:
<main> <main>
<article> <article>
<header> <header>
<h1>{{.Title }}</h1> <h1>{{ .Title }}</h1>
{{ with .Params.subtitle }} {{ with .Params.subtitle }}
<span>{{.}}</span> <span>{{ . }}</span>
</header> </header>
<div> <div>
{{.Content }} {{ .Content }}
</div> </div>
<aside> <aside>
{{.TableOfContents }} {{ .TableOfContents }}
</aside> </aside>
</article> </article>
</main> </main>
+16 -16
View File
@@ -30,24 +30,24 @@ You can use `after` in combination with the [`first` function] and Hugo's [power
{{< code file="layouts/section/articles.html" download="articles.html" >}} {{< code file="layouts/section/articles.html" download="articles.html" >}}
{{ define "main" }} {{ define "main" }}
<section class="row featured-article"> <section class="row featured-article">
<h2>Featured Article</h2> <h2>Featured Article</h2>
{{ range first 1 .Pages.ByPublishDate.Reverse }} {{ range first 1 .Pages.ByPublishDate.Reverse }}
<header> <header>
<h3><a href="{{.Permalink }}">{{.Title }}</a></h3> <h3><a href="{{ . Permalink }}">{{ .Title }}</a></h3>
</header> </header>
<p>{{.Description }}</p> <p>{{ .Description }}</p>
{{ end }} {{ end }}
</section> </section>
<div class="row recent-articles"> <div class="row recent-articles">
<h2>Recent Articles</h2> <h2>Recent Articles</h2>
{{ range first 3 (after 1 .Pages.ByPublishDate.Reverse) }} {{ range first 3 (after 1 .Pages.ByPublishDate.Reverse) }}
<section class="recent-article"> <section class="recent-article">
<header> <header>
<h3><a href="{{.Permalink }}">{{.Title }}</a></h3> <h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
</header> </header>
<p>{{.Description }}</p> <p>{{ .Description }}</p>
</section> </section>
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
+1 -1
View File
@@ -16,5 +16,5 @@ relatedfuncs: [truncate]
Useful in a pipeline to remove newlines added by other processing (e.g., [`markdownify`](/functions/markdownify/)). Useful in a pipeline to remove newlines added by other processing (e.g., [`markdownify`](/functions/markdownify/)).
```go-html-template ```go-html-template
{{ chomp "<p>Blockhead</p>\n"}} → "<p>Blockhead</p>" {{ chomp "<p>Blockhead</p>\n" }} → "<p>Blockhead</p>"
``` ```
+2 -2
View File
@@ -71,13 +71,13 @@ The following have equivalent return values but are far less terse. This demonst
Using `if`: Using `if`:
{{< code file="if-instead-of-default.html" copy="false" >}} {{< code file="if-instead-of-default.html" copy="false" >}}
<title>{{ if .Params.seo_title }}{{.Params.seo_title }}{{ else }}{{.Title }}{{ end }}</title> <title>{{ if .Params.seo_title }}{{ .Params.seo_title }}{{ else }}{{ .Title }}{{ end }}</title>
=> Sane Defaults => Sane Defaults
{{< /code >}} {{< /code >}}
Using `with`: Using `with`:
{{< code file="with-instead-of-default.html" copy="false" >}} {{< code file="with-instead-of-default.html" copy="false" >}}
<title>{{ with .Params.seo_title }}{{.}}{{ else }}{{.Title }}{{ end }}</title> <title>{{ with .Params.seo_title }}{{ . }}{{ else }}{{ .Title }}{{ end }}</title>
=> Sane Defaults => Sane Defaults
{{< /code >}} {{< /code >}}
+1 -1
View File
@@ -89,7 +89,7 @@ An example table listing the dependencies:
{{ range $index, $element := hugo.Deps }} {{ range $index, $element := hugo.Deps }}
<tr> <tr>
<th scope="row">{{ add $index 1 }}</th> <th scope="row">{{ add $index 1 }}</th>
<td>{{ with $element.Owner }}{{.Path }}{{ end }}</td> <td>{{ with $element.Owner }}{{ .Path }}{{ end }}</td>
<td> <td>
{{ $element.Path }} {{ $element.Path }}
{{ with $element.Replace }} {{ with $element.Replace }}
+3 -3
View File
@@ -14,8 +14,8 @@ If the input is either an int64 value or the string representation of an integer
```go-html-template ```go-html-template
{{ humanize "my-first-post"}} → "My first post" {{ humanize "my-first-post" }} → "My first post"
{{ humanize "myCamelPost"}} → "My camel post" {{ humanize "myCamelPost" }} → "My camel post"
{{ humanize "52"}} → "52nd" {{ humanize "52" }} → "52nd"
{{ humanize 103 }} → "103rd" {{ humanize 103 }} → "103rd"
``` ```
+3 -3
View File
@@ -45,7 +45,7 @@ images.Text TEXT DICT)
The following example will add the text `Hugo rocks!` to the image with the specified color, size and position. The following example will add the text `Hugo rocks!` to the image with the specified color, size and position.
```go-html-template ```go-html-template
{{ $img := resources.Get "/images/background.png"}} {{ $img := resources.Get "/images/background.png" }}
{{ $img = $img.Filter (images.Text "Hugo rocks!" (dict {{ $img = $img.Filter (images.Text "Hugo rocks!" (dict
"color" "#ffffff" "color" "#ffffff"
"size" 60 "size" 60
@@ -60,7 +60,7 @@ You can load a custom font if needed. Load the font as a Hugo `Resource` and set
```go-html-template ```go-html-template
{{ $font := resources.GetRemote "https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Black.ttf" }} {{ $font := resources.GetRemote "https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Black.ttf" }}
{{ $img := resources.Get "/images/background.png"}} {{ $img := resources.Get "/images/background.png" }}
{{ $img = $img.Filter (images.Text "Hugo rocks!" (dict {{ $img = $img.Filter (images.Text "Hugo rocks!" (dict
"font" $font "font" $font
))}} ))}}
@@ -221,6 +221,6 @@ images.ImageConfig PATH
```go-html-template ```go-html-template
{{ with (imageConfig "favicon.ico") }} {{ with (imageConfig "favicon.ico") }}
favicon.ico: {{.Width }} x {{.Height }} favicon.ico: {{ .Width }} x {{ .Height }}
{{ end }} {{ end }}
``` ```
+1 -1
View File
@@ -17,6 +17,6 @@ Takes either a slice, array, or channel and an index or a map and a key as input
``` ```
{{% warning %}} {{% warning %}}
All site-level configuration keys are stored as lower case. Therefore, a `myParam` key-value set in your [site configuration file](/getting-started/configuration/) needs to be accessed with `{{ if isset .Site.Params "myparam"}}` and *not* with `{{ if isset .Site.Params "myParam"}}`. Note that you can still access the same config key with `.Site.Params.myParam` *or* `.Site.Params.myparam`, for example, when using [`with`](/functions/with). All site-level configuration keys are stored as lower case. Therefore, a `myParam` key-value set in your [site configuration file](/getting-started/configuration/) needs to be accessed with `{{ if isset .Site.Params "myparam" }}` and *not* with `{{ if isset .Site.Params "myParam" }}`. Note that you can still access the same config key with `.Site.Params.myParam` *or* `.Site.Params.myparam`, for example, when using [`with`](/functions/with).
This restriction also applies when accessing page-level front matter keys from within [shortcodes](/content-management/shortcodes/). This restriction also applies when accessing page-level front matter keys from within [shortcodes](/content-management/shortcodes/).
{{% /warning %}} {{% /warning %}}
+1 -1
View File
@@ -30,7 +30,7 @@ You may want to append a class to a heading according to the length of the strin
{{< code file="check-title-length.html" >}} {{< code file="check-title-length.html" >}}
<header> <header>
<h1{{ if gt (len .Title) 80 }} class="long-title"{{ end }}>{{.Title }}</h1> <h1{{ if gt (len .Title) 80 }} class="long-title"{{ end }}>{{ .Title }}</h1>
</header> </header>
{{< /code >}} {{< /code >}}
+1 -1
View File
@@ -16,7 +16,7 @@ For example, building your site on June 24, 2017, with the following templating:
```go-html-template ```go-html-template
<div> <div>
<small>&copy; {{ now.Format "2006"}}</small> <small>&copy; {{ now.Format "2006" }}</small>
</div> </div>
``` ```
+1 -1
View File
@@ -18,7 +18,7 @@ This example could render a piece of content using the content view located at `
```go-html-template ```go-html-template
{{ range .Pages }} {{ range .Pages }}
{{ .Render "summary"}} {{ .Render "summary" }}
{{ end }} {{ end }}
``` ```
+1 -1
View File
@@ -10,4 +10,4 @@ signature: ["string INPUT"]
relatedfuncs: [] relatedfuncs: []
--- ---
* `{{ string "BatMan"}}` → "BatMan" * `{{ string "BatMan" }}` → "BatMan"
+2 -2
View File
@@ -22,9 +22,9 @@ The following might be used as a partial within a [single page template][singlet
{{< code file="layouts/partials/content-header.html" download="content-header.html" >}} {{< code file="layouts/partials/content-header.html" download="content-header.html" >}}
<header> <header>
<h1>{{.Title }}</h1> <h1>{{ .Title }}</h1>
{{ with .Params.location }} {{ with .Params.location }}
<div><a href="/locations/{{ . | urlize }}">{{.}}</a></div> <div><a href="/locations/{{ . | urlize }}">{{ . }}</a></div>
{{ end }} {{ end }}
<!-- Creates a list of tags for the content and links to each of their pages --> <!-- Creates a list of tags for the content and links to each of their pages -->
{{ with .Params.tags }} {{ with .Params.tags }}
+1 -1
View File
@@ -77,7 +77,7 @@ The following logical operators are available with `where`:
When using booleans you should not put quotation marks. When using booleans you should not put quotation marks.
```go-html-template ```go-html-template
{{ range where .Pages "Draft" true }} {{ range where .Pages "Draft" true }}
<p>{{.Title }}</p> <p>{{ .Title }}</p>
{{ end }} {{ end }}
``` ```
+2 -2
View File
@@ -20,8 +20,8 @@ The following example checks for a [user-defined site variable](/variables/site/
{{< code file="layouts/partials/twitter.html" >}} {{< code file="layouts/partials/twitter.html" >}}
{{ with .Site.Params.twitteruser }}<span class="twitter"> {{ with .Site.Params.twitteruser }}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author"> <a href="https://twitter.com/{{ . }}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}" <img src="/images/twitter.png" width="48" height="48" title="Twitter: {{ . }}"
alt="Twitter"></a> alt="Twitter"></a>
</span>{{ end }} </span>{{ end }}
{{< /code >}} {{< /code >}}
+2 -2
View File
@@ -19,13 +19,13 @@ See [Image Processing Options](https://gohugo.io/content-management/image-proces
Another useful addon is the `$pages.Next` and `$pages.Prev` methods on the core page collections in Hugo. These works the same way as the built-in static variants one `Page`, e.g. `.Next` and `.NextInSection`: Another useful addon is the `$pages.Next` and `$pages.Prev` methods on the core page collections in Hugo. These works the same way as the built-in static variants one `Page`, e.g. `.Next` and `.NextInSection`:
``` ```
{{ with .Site.RegularPages.Next . }}{{.RelPermalink }}{{ end }} {{ with .Site.RegularPages.Next . }}{{ .RelPermalink }}{{ end }}
``` ```
The above is a functionally equivalent (but slightly slower) variant of: The above is a functionally equivalent (but slightly slower) variant of:
``` ```
{{ with .Next }}{{.RelPermalink }}{{ end }} {{ with .Next }}{{ .RelPermalink }}{{ end }}
``` ```
See [Pages Methods](https://gohugo.io/variables/pages/) for more information. See [Pages Methods](https://gohugo.io/variables/pages/) for more information.
+1 -1
View File
@@ -61,7 +61,7 @@ Spelled-out cardinal numbers (e.g. "one", "two", and "three") and ordinal abbrev
To continue with the example above: To continue with the example above:
```go-html-template ```go-html-template
{{.Date.Format "Jan 2nd 2006"}} {{ .Date.Format "Jan 2nd 2006" }}
``` ```
Hugo assumes you want to append `nd` as a string to the day of the month and outputs the following: Hugo assumes you want to append `nd` as a string to the day of the month and outputs the following:
+6 -6
View File
@@ -27,12 +27,12 @@ In addition to the standard page variables, the 404 page has access to all site
This is a basic example of a 404.html template: This is a basic example of a 404.html template:
{{< code file="layouts/404.html" download="404.html" >}} {{< code file="layouts/404.html" download="404.html" >}}
{{ define "main"}} {{ define "main" }}
<main id="main"> <main id="main">
<div> <div>
<h1 id="title"><a href="{{ "" | relURL }}">Go Home</a></h1> <h1 id="title"><a href="{{ "" | relURL }}">Go Home</a></h1>
</div> </div>
</main> </main>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
+1 -1
View File
@@ -82,7 +82,7 @@ The following shows how you can override both the `"main"` and `"title"` block a
{{< code file="layouts/_default/single.html" download="single.html" >}} {{< code file="layouts/_default/single.html" download="single.html" >}}
{{ define "title" }} {{ define "title" }}
<!-- This will override the default value set in baseof.html; i.e., "{{.Site.Title }}" in the original example--> <!-- This will override the default value set in baseof.html; i.e., "{{ .Site.Title }}" in the original example-->
{{ .Title }} &ndash; {{ .Site.Title }} {{ .Title }} &ndash; {{ .Site.Title }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
+1 -1
View File
@@ -127,7 +127,7 @@ Achievements:
You can use the following code to render the `Short Description` in your layout: You can use the following code to render the `Short Description` in your layout:
```go-html-template ```go-html-template
<div>Short Description of {{.Site.Data.User0123.Name }}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div> <div>Short Description of {{ .Site.Data.User0123.Name }}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div>
``` ```
Note the use of the [`markdownify` template function][markdownify]. This will send the description through the Markdown rendering engine. Note the use of the [`markdownify` template function][markdownify]. This will send the description through the Markdown rendering engine.
+18 -18
View File
@@ -33,27 +33,27 @@ See the homepage template below or [Content Organization][contentorg] for more i
## Example Homepage Template ## Example Homepage Template
The following is an example of a homepage template that uses [partial][partials], [base] templates, and a content file at `content/_index.md` to populate the `{{.Title }}` and `{{.Content }}` [page variables][pagevars]. The following is an example of a homepage template that uses [partial][partials], [base] templates, and a content file at `content/_index.md` to populate the `{{ .Title }}` and `{{ .Content }}` [page variables][pagevars].
{{< code file="layouts/index.html" download="index.html" >}} {{< code file="layouts/index.html" download="index.html" >}}
{{ define "main" }} {{ define "main" }}
<main aria-role="main"> <main aria-role="main">
<header class="homepage-header"> <header class="homepage-header">
<h1>{{.Title }}</h1> <h1>{{ .Title }}</h1>
{{ with .Params.subtitle }} {{ with .Params.subtitle }}
<span class="subtitle">{{.}}</span> <span class="subtitle">{{ . }}</span>
{{ end }} {{ end }}
</header> </header>
<div class="homepage-content"> <div class="homepage-content">
<!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md --> <!-- Note that the content for index.html, as a sort of list page, will pull from content/_index.md -->
{{.Content }} {{ .Content }}
</div> </div>
<div> <div>
{{ range first 10 .Site.RegularPages }} {{ range first 10 .Site.RegularPages }}
{{ .Render "summary"}} {{ .Render "summary" }}
{{ end }} {{ end }}
</div> </div>
</main> </main>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
+7 -7
View File
@@ -544,11 +544,11 @@ Here is an example of corresponding code that could be used inside a `toc.html`
{{ if not .Params.notoc }} {{ if not .Params.notoc }}
<aside> <aside>
<header> <header>
<a href="#{{.Title | urlize }}"> <a href="#{{ .Title | urlize }}">
<h3>{{.Title }}</h3> <h3>{{ .Title }}</h3>
</a> </a>
</header> </header>
{{.TableOfContents }} {{ .TableOfContents }}
</aside> </aside>
<a href="#" id="toc-toggle"></a> <a href="#" id="toc-toggle"></a>
{{ end }} {{ end }}
@@ -574,7 +574,7 @@ Within a footer layout, you might then declare a `<footer>` that is only rendere
```go-html-template ```go-html-template
{{ if .Site.Params.copyrighthtml }} {{ if .Site.Params.copyrighthtml }}
<footer> <footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHTML }}</div> <div class="text-center">{{ .Site.Params.CopyrightHTML | safeHTML }}</div>
</footer> </footer>
{{ end }} {{ end }}
``` ```
@@ -584,8 +584,8 @@ An alternative way of writing the "`if`" and then referencing the same value is
{{< code file="layouts/partials/twitter.html" >}} {{< code file="layouts/partials/twitter.html" >}}
{{ with .Site.Params.twitteruser }} {{ with .Site.Params.twitteruser }}
<div> <div>
<a href="https://twitter.com/{{.}}" rel="author"> <a href="https://twitter.com/{{ . }}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}" alt="Twitter"></a> <img src="/images/twitter.png" width="48" height="48" title="Twitter: {{ . }}" alt="Twitter"></a>
</div> </div>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
@@ -597,7 +597,7 @@ Finally, you can pull "magic constants" out of your layouts as well. The followi
<h1>Recent Posts</h1> <h1>Recent Posts</h1>
<ul> <ul>
{{- range first .Site.Params.SidebarRecentLimit .Site.Pages -}} {{- range first .Site.Params.SidebarRecentLimit .Site.Pages -}}
<li><a href="{{.RelPermalink }}">{{.Title }}</a></li> <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end -}} {{- end -}}
</ul> </ul>
</nav> </nav>
+18 -18
View File
@@ -87,21 +87,21 @@ You can now access this `_index.md`'s' content in your list template:
{{< code file="layouts/_default/list.html" download="list.html" >}} {{< code file="layouts/_default/list.html" download="list.html" >}}
{{ define "main" }} {{ define "main" }}
<main> <main>
<article> <article>
<header> <header>
<h1>{{.Title}}</h1> <h1>{{ .Title} }</h1>
</header> </header>
<!-- "{{.Content}}" pulls from the markdown content of the corresponding _index.md --> <!-- "{{ .Content} }" pulls from the markdown content of the corresponding _index.md -->
{{.Content}} {{ .Content }}
</article> </article>
<ul> <ul>
<!-- Ranges through content/posts/*.md --> <!-- Ranges through content/posts/*.md -->
{{ range .Pages }} {{ range .Pages }}
<li> <li>
<a href="{{.Permalink}}">{{.Date.Format "2006-01-02"}} | {{.Title}}</a> <a href="{{ .Permalink }}">{{ .Date.Format "2006-01-02" }} | {{ .Title }}</a>
</li> </li>
{{ end }} {{ end }}
</ul> </ul>
</main> </main>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
@@ -128,7 +128,7 @@ This above will output the following HTML:
### List Pages Without `_index.md` ### List Pages Without `_index.md`
You do *not* have to create an `_index.md` file for every list page (i.e. section, taxonomy, taxonomy terms, etc) or the homepage. If Hugo does not find an `_index.md` within the respective content section when rendering a list template, the page will be created but with no `{{.Content}}` and only the default values for `.Title` etc. You do *not* have to create an `_index.md` file for every list page (i.e. section, taxonomy, taxonomy terms, etc) or the homepage. If Hugo does not find an `_index.md` within the respective content section when rendering a list template, the page will be created but with no `{{ .Content }}` and only the default values for `.Title` etc.
Using this same `layouts/_default/list.html` template and applying it to the `quotes` section above will render the following output. Note that `quotes` does not have an `_index.md` file to pull from: Using this same `layouts/_default/list.html` template and applying it to the `quotes` section above will render the following output. Note that `quotes` does not have an `_index.md` file to pull from:
@@ -168,7 +168,7 @@ This list template has been modified slightly from a template originally used in
<ul> <ul>
<!-- Renders the li.html content view for each content/posts/*.md --> <!-- Renders the li.html content view for each content/posts/*.md -->
{{ range .Pages }} {{ range .Pages }}
{{ .Render "li"}} {{ .Render "li" }}
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
@@ -185,7 +185,7 @@ This list template has been modified slightly from a template originally used in
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
<!-- ranges through each of the content files associated with a particular taxonomy term and renders the summary.html content view --> <!-- ranges through each of the content files associated with a particular taxonomy term and renders the summary.html content view -->
{{ range .Pages }} {{ range .Pages }}
{{ .Render "summary"}} {{ .Render "summary" }}
{{ end }} {{ end }}
</div> </div>
</main> </main>
@@ -376,14 +376,14 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
In the above example, you may want `{{.Title}}` to point the `title` field you have added to your `_index.md` file instead. You can access this value using the [`.GetPage` function][getpage]: In the above example, you may want `{{ .Title }}` to point the `title` field you have added to your `_index.md` file instead. You can access this value using the [`.GetPage` function][getpage]:
{{< code file="layouts/partials/by-page-field.html" >}} {{< code file="layouts/partials/by-page-field.html" >}}
<!-- Groups content according to content section.--> <!-- Groups content according to content section.-->
{{ range .Pages.GroupBy "Section" }} {{ range .Pages.GroupBy "Section" }}
<!-- Checks for existence of _index.md for a section; if available, pulls from "title" in front matter --> <!-- Checks for existence of _index.md for a section; if available, pulls from "title" in front matter -->
{{ with $.Site.GetPage "section" .Key }} {{ with $.Site.GetPage "section" .Key }}
<h3>{{.Title}}</h3> <h3>{{ .Title }}</h3>
{{ else }} {{ else }}
<!-- If no _index.md is available, ".Key" defaults to the section title and filters to title casing --> <!-- If no _index.md is available, ".Key" defaults to the section title and filters to title casing -->
<h3>{{ .Key | title }}</h3> <h3>{{ .Key | title }}</h3>
@@ -539,7 +539,7 @@ While these are logical defaults, they are not always the desired order. There a
### Order Within Groups ### Order Within Groups
Because Grouping returns a `{{.Key}}` and a slice of pages, all the ordering methods listed above are available. Because Grouping returns a `{{ .Key }}` and a slice of pages, all the ordering methods listed above are available.
Here is the ordering for the example that follows: Here is the ordering for the example that follows:
+1 -1
View File
@@ -49,7 +49,7 @@ Examples:
{{ .Content }} {{ .Content }}
<ul class="contents"> <ul class="contents">
{{ range .Paginator.Pages }} {{ range .Paginator.Pages }}
<li>{{.Title }} <li>{{ .Title }}
<div> <div>
{{ partial "summary.html" . }} {{ partial "summary.html" . }}
</div> </div>
+11 -11
View File
@@ -209,21 +209,21 @@ You have created the shortcode at `/layouts/shortcodes/img.html`, which loads th
{{< code file="/layouts/shortcodes/img.html" >}} {{< code file="/layouts/shortcodes/img.html" >}}
<!-- image --> <!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}> <figure {{ with .Get "class" }}class="{{ . }}"{{ end }}>
{{ with .Get "link" }}<a href="{{ . }}">{{ end }} {{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }} /> <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link" }}</a>{{ end }} {{ if .Get "link" }}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }} {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }}
<figcaption>{{ if isset .Params "title" }} <figcaption>{{ if isset .Params "title" }}
<h4>{{ .Get "title" }}</h4>{{ end }} <h4>{{ .Get "title" }}</h4>{{ end }}
{{ if or (.Get "caption") (.Get "attr") }}<p> {{ if or (.Get "caption") (.Get "attr") }}<p>
{{ .Get "caption" }} {{ .Get "caption" }}
{{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }} {{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }}
{{ .Get "attr" }} {{ .Get "attr" }}
{{ if .Get "attrlink" }}</a> {{ end }} {{ if .Get "attrlink" }}</a> {{ end }}
</p> {{ end }} </p> {{ end }}
</figcaption> </figcaption>
{{ end }} {{ end }}
</figure> </figure>
<!-- image --> <!-- image -->
{{< /code >}} {{< /code >}}
@@ -232,10 +232,10 @@ Would be rendered as:
{{< code file="img-output.html" copy="false" >}} {{< code file="img-output.html" copy="false" >}}
<figure> <figure>
<img src="/media/spf13.jpg" /> <img src="/media/spf13.jpg" />
<figcaption> <figcaption>
<h4>Steve Francia</h4> <h4>Steve Francia</h4>
</figcaption> </figcaption>
</figure> </figure>
{{< /code >}} {{< /code >}}
+29 -29
View File
@@ -30,40 +30,40 @@ This single page template makes use of Hugo [base templates], the [`.Format` fun
<section id="main"> <section id="main">
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
<div> <div>
<article id="content"> <article id="content">
{{ .Content }} {{ .Content }}
</article> </article>
</div> </div>
</section> </section>
<aside id="meta"> <aside id="meta">
<div> <div>
<section> <section>
<h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4> <h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4>
<h5 id="wordcount"> {{ .WordCount }} Words </h5> <h5 id="wordcount"> {{ .WordCount }} Words </h5>
</section> </section>
{{ with .GetTerms "topics" }} {{ with .GetTerms "topics" }}
<ul id="topics"> <ul id="topics">
{{ range . }} {{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li> <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ with .GetTerms "tags" }}
<ul id="tags">
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
</div>
<div>
{{ with .PrevInSection }}
<a class="previous" href="{{.Permalink }}"> {{.Title }}</a>
{{ end }} {{ end }}
{{ with .NextInSection }} </ul>
<a class="next" href="{{.Permalink }}"> {{.Title }}</a> {{ end }}
{{ with .GetTerms "tags" }}
<ul id="tags">
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }} {{ end }}
</div> </ul>
{{ end }}
</div>
<div>
{{ with .PrevInSection }}
<a class="previous" href="{{ .Permalink }}"> {{ .Title }}</a>
{{ end }}
{{ with .NextInSection }}
<a class="next" href="{{ .Permalink }}"> {{ .Title }}</a>
{{ end }}
</div>
</aside> </aside>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
+4 -4
View File
@@ -65,10 +65,10 @@ In this example, `.Render` is passed into the template to call the [render funct
{{< code file="layouts/_default/list.html" download="list.html" >}} {{< code file="layouts/_default/list.html" download="list.html" >}}
<main id="main"> <main id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
{{ range .Pages }} {{ range .Pages }}
{{ .Render "summary"}} {{ .Render "summary" }}
{{ end }} {{ end }}
</div> </div>
</main> </main>
{{< /code >}} {{< /code >}}
+4 -4
View File
@@ -90,10 +90,10 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
: access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`. : access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`.
.Next .Next
: Points up to the next [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ with .Next }}{{.Permalink }}{{ end }}`. Calling `.Next` from the first page returns `nil`. : Points up to the next [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ with .Next }}{{ .Permalink }}{{ end }}`. Calling `.Next` from the first page returns `nil`.
.NextInSection .NextInSection
: Points up to the next [regular page](/variables/site/#site-pages) below the same top level section (e.g. in `/blog`)). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ with .NextInSection }}{{.Permalink }}{{ end }}`. Calling `.NextInSection` from the first page returns `nil`. : Points up to the next [regular page](/variables/site/#site-pages) below the same top level section (e.g. in `/blog`)). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ with .NextInSection }}{{ .Permalink }}{{ end }}`. Calling `.NextInSection` from the first page returns `nil`.
.OutputFormats .OutputFormats
: contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).) : contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).)
@@ -112,10 +112,10 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
: the slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields). : the slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields).
.Prev .Prev
: Points down to the previous [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ if .Prev }}{{.Prev.Permalink }}{{ end }}`. Calling `.Prev` from the last page returns `nil`. : Points down to the previous [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ if .Prev }}{{ .Prev.Permalink }}{{ end }}`. Calling `.Prev` from the last page returns `nil`.
.PrevInSection .PrevInSection
: Points down to the previous [regular page](/variables/site/#site-pages) below the same top level section (e.g. `/blog`). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ if .PrevInSection }}{{.PrevInSection.Permalink }}{{ end }}`. Calling `.PrevInSection` from the last page returns `nil`. : Points down to the previous [regular page](/variables/site/#site-pages) below the same top level section (e.g. `/blog`). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ if .PrevInSection }}{{ .PrevInSection.Permalink }}{{ end }}`. Calling `.PrevInSection` from the last page returns `nil`.
.PublishDate .PublishDate
: the date on which the content was or will be published; `.Publishdate` pulls from the `publishdate` field in a content's front matter. See also `.ExpiryDate`, `.Date`, and `.Lastmod`. : the date on which the content was or will be published; `.Publishdate` pulls from the `publishdate` field in a content's front matter. See also `.ExpiryDate`, `.Date`, and `.Lastmod`.
+2 -2
View File
@@ -18,8 +18,8 @@ Also see [List templates](/templates/lists) for an overview of sort methods.
`.Next` and `.Prev` on `Pages` work similar to the methods with the same names on `.Page`, but are more flexible (and slightly slower) as they can be used on any page collection. `.Next` and `.Prev` on `Pages` work similar to the methods with the same names on `.Page`, but are more flexible (and slightly slower) as they can be used on any page collection.
`.Next` points **up** to the next page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Next . }}{{.RelPermalink }}{{ end }}`. Calling `.Next` with the first page in the collection returns `nil`. `.Next` points **up** to the next page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Next . }}{{ .RelPermalink }}{{ end }}`. Calling `.Next` with the first page in the collection returns `nil`.
## .Prev PAGE ## .Prev PAGE
`.Prev` points **down** to the previous page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Prev . }}{{.RelPermalink }}{{ end }}`. Calling `.Prev` with the last page in the collection returns `nil`. `.Prev` points **down** to the previous page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Prev . }}{{ .RelPermalink }}{{ end }}`. Calling `.Prev` with the last page in the collection returns `nil`.
+1 -1
View File
@@ -111,7 +111,7 @@ baseURL = "https://yoursite.example.com/"
You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description: You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description:
{{< code file="layouts/partials/head.html" >}} {{< code file="layouts/partials/head.html" >}}
<meta name="description" content="{{ if .IsHome }}{{ $.Site.Params.description }}{{ else }}{{.Description }}{{ end }}" /> <meta name="description" content="{{ if .IsHome }}{{ $.Site.Params.description }}{{ else }}{{ .Description }}{{ end }}" />
{{< /code >}} {{< /code >}}
## The `.Site.Pages` Variable {#site-pages} ## The `.Site.Pages` Variable {#site-pages}