Squashed 'docs/' changes from b654fcba0..60dd993a6

60dd993a6 content: Update GitHub Pages workflow
6247e3590 content: Fix typo
a22255b0b content: Update version references
21afec198 content: Update version reference
6226532c8 content: Update version reference
80d26621a content: Update version reference
cda7135b5 content: Fix typo
70c509e8a content: Fix typo
136b20310 content: Change render hook example
038246c2f content: Fix accidental removal
441375fa4 netlify: Hugo 0.147.9
4a620931c content: Note that config/env/cascade.xxx is not supported
6d3a7587f config: Ignore front matter param override warnings
623b48624 content: Set searchable param to false for content/en/documentation.md
d1b2aad69 content: Fix Codeberg deployment article
5e3d849b8 search: Use front matter parameter to control search indexing
b4f90e39d content: Note that PATH segments must exclude project directory
a81406e26 content: Create aliases for deleted template pages
7c3adc9ad content: Change order of template types
e093eb036 content: Remove admonition from template types page
0015e7a9b content: Update to align with v0.146.0 template system (phase 1)
cf986240d content: Update templates.Defer note
ab51fdcc7 content: Use consistent templates.Defer examples
b4f8e492f content: Fix formatting
62aa94add content: Fix typo
83747f36b content: Update FAQs
fc644d894 Update netlify.toml
4151f3a5b content: Fix typo
9452bca92 content: Update description ToMath strict option
982b863c3 content: Add instructions about deploying to root of user's Codeberg Pages
fc7cd2878 theme: Generate QR code once per page
784891b87 content: Update links to the CommonMark specification
741113fb5 content: Fix incorrect link to Shortcodes tutorial
c4962f1ac content: Update transform.ToMath
ad7b87223 Update netlify.toml
2d64e57ae theme: Remove bullet from new-in badge
55a832f8e Update ToMath.md
e1e624f49 content: Document transform.ToMath strict mode
2df6218f8 netlify: Hugo 0.147.6
0259b88f1 Revert "theme: Display date on news items from content adapter"
43b35e56a theme: Adjust admonition dark mode colors
2f15e9c34 theme: Add link to Mastodon
d99e979d4 theme: Display date on news items from content adapter
6c93dac97 content: Clarify the AddResource content value
49006468e content: Describe Codeberg's Forgejo Actions
be80c3b82 content: Update css.TailwindCSS opts
b3ba4329c theme: Update css.TailwindCSS opts and remove tailwind.config.js
902e360b0 content: Update stylesheet link for katex.js
8b9e1ba3e content: Update stylesheet link for katex.js
7dae3b0e8 content: Update TailwindCSS instructions
cb093d210 Update netlify.toml
577d6fbb1 content: Remove GitCMS for now
8352af6cd Updates for v0.147.4
2240f07a5 content: Fix typo
677b3fed3 Correct openapi3.Unmarshal example
580477aa5 content: Fix typo
0dc43b481 content: Add GitCMS to commercial front ends list
ac4179f2b content: Fix relref shortcode examples
a699d267b Fix typos
7e28c4380 Make sponsor logo responsive
8e05f0425 Update MaxInt64.md
f715265d3 content: Document math.MaxInt64
0d57ff7d4 Update netlify.toml
d210e3476 theme: Adjust sponsor
e73444b43 content: Clarify page title values
fd4c292b8 content: Fix links to Pandoc
dd074dc67 content: Bump version in GitHub Pages example
fe5537bb2 content: Describe the pandoc format
10834529e theme: Remove duplicate meta element
838706d6e theme: More changes related to new template system
b0b6b1e69 Update new-templatesystem-overview.md
e719d2360 Update new-templatesystem-overview.md
ec2bbd395 Update new-templatesystem-overview.md
53319a681 Add a one pager about the new template system
e17416c05 Fix the spelling issue on the Host on Render description
e8e1c82aa content: Document range-over-int introduced in v0.123.0
bc478f98f content: Fix editing errors
606547b48 Update netlify.toml
e224f3f82 content: Fix formatting
24e4acc41 content: Fix typo
1e773f34b content: Fix typo
5ef94a725 content: Document alternative to shuffle for large collections
7fe42d76c content: Fix sample code formatting
5d601448f content: Update mathematical markup guidance
63b4fe2c0 content: Update version references
722da91f1 content: Fix GO_VERSION in Netlify hosting example
8cc589c3a theme: Add current Hugo version to the header
37aa24ac5 netlify: Hugo 0.147.1
a80b25e24 content: Remove dated new-in
89dcf0f92 content: Fix path formatting
1a5191d78 content: Update transformation examples
3327065ab Update Text.md
557c10dd2 content: Miscellaneous updates for v0.147.0
0dae1a185 netlify: Hugo 0.147.0
9b44821c3 Merge branch 'tempv0.147.0'
f1481e8c3 content: Update GitLab Pages workflow example
2e61a0360 content: Update content format descriptions
fb42d7c2a images: Add option for vertical alignment to images.Text

git-subtree-dir: docs
git-subtree-split: 60dd993a651f1b58c5dabf0e3896f1e96bb846ff
This commit is contained in:
Bjørn Erik Pedersen
2025-07-07 13:16:31 +02:00
parent b3d87dd0fd
commit bb147f91ee
162 changed files with 1627 additions and 2288 deletions

View File

@@ -70,6 +70,7 @@
"# cspell: ignore hugo terminology",
"# ----------------------------------------------------------------------",
"alignx",
"aligny",
"attrlink",
"canonify",
"codeowners",

View File

@@ -2,16 +2,16 @@
**/icons.html
# These are whitespace sensitive.
layouts/_default/_markup/render-code*
layouts/_default/_markup/render-table*
layouts/shortcodes/glossary-term.html
layouts/shortcodes/glossary.html
layouts/shortcodes/highlighting-styles.html
layouts/shortcodes/list-pages-in-section.html
layouts/shortcodes/quick-reference.html
layouts/_markup/render-code*
layouts/_markup/render-table*
layouts/_shortcodes/glossary-term.html
layouts/_shortcodes/glossary.html
layouts/_shortcodes/highlighting-styles.html
layouts/_shortcodes/list-pages-in-section.html
layouts/_shortcodes/quick-reference.html
# No root node.
layouts/partials/layouts/head/head.html
layouts/_partials/layouts/head/head.html
# Auto generated.
assets/css/components/chroma*.css

View File

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 299 118" height="100%" width="100%" style="enable-background:new 0 0 299 118;" xml:space="preserve">
<style type="text/css">
.st0{clip-path:url(#SVGID_2_);}
.st1{fill:#414141;}
.st2{fill:#3D4DF4;}
</style>
<g>
<defs>
<rect id="SVGID_1_" x="0.4" y="0" width="66.5" height="67.8"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" style="overflow:visible;"/>
</clipPath>
<g class="st0">
<path class="st1" d="M34.2,28l31.4,18.3c0.9,0.5,1.1,1.6,0.6,2.4c-0.2,0.3-0.4,0.5-0.6,0.6L35.6,66.9c-1.4,0.8-3.1,0.8-4.5,0
L1.3,49.6c-0.9-0.5-1.1-1.6-0.6-2.4c0.2-0.3,0.4-0.5,0.6-0.6l23-13.4l7.9,13.6c0.5,0.8,1.5,1.1,2.4,0.7l0.1,0l0.1,0
c0.6-0.4,0.9-1.2,0.7-2l-5-15.7l2.5-1.5C33.3,27.8,33.8,27.8,34.2,28z M36,58.6c-1.4-0.8-3.9-0.7-5.5,0.3l-3,1.7l7,4.1l2-1.2
l-2-1.1l1-0.6C37.1,60.9,37.3,59.4,36,58.6z M32.1,59.9c0.6-0.3,1.4-0.4,1.8-0.1c0.5,0.3,0.4,0.7-0.2,1.1l-1,0.6l-1.7-1L32.1,59.9
z M36.2,55.6l-2,1.2l7,4.1l2-1.2L36.2,55.6z M42.6,51.9l-2,1.2l2.9,1.7l-4.5-0.8L37,55.1l7,4.1l2-1.2L43,56.3l4.5,0.8l2.1-1.2
L42.6,51.9z M56.3,43.8l-6,3.5l2.5,1.4l-3.7-0.7L47,49.3l2.9,1.7l-4.5-0.8l-2.1,1.2l7,4.1l2-1.2l-2.9-1.7l4.5,0.8l2.1-1.2
l-2.9-1.7l4,0.7l0.2,0.1l2-1.2l4-2.3l-1.7-1l-4,2.3l-1-0.6l4-2.3l-1.7-1l-4,2.3L54,47.1l4-2.3L56.3,43.8z"/>
<path class="st2" d="M41.7,0c0.1,0,0.2,0,0.3,0c1,0.2,1.6,1.1,1.5,2.1l-2.3,13.5c3.9,2.5,6.5,6.9,6.5,11.9v0.7l-10.3,0l-2,17.9
c-0.1,0.8-0.7,1.4-1.5,1.5l-0.1,0c-1,0.1-1.9-0.6-2-1.5l-2-17.9H19.6v-0.7c0-5,2.6-9.4,6.5-11.9L23.8,2.1c0-0.1,0-0.2,0-0.3
c0-1,0.8-1.8,1.8-1.8H41.7z"/>
</g>
</g>
<path class="st1" d="M277.4,61c-3.7,0-7.1-0.8-10-2.4c-2.8-1.6-5.1-3.9-6.7-6.8c-1.6-2.9-2.4-6.4-2.4-10.3v-0.9
c0-4,0.8-7.4,2.4-10.3c1.6-2.9,3.8-5.2,6.6-6.8c2.8-1.6,6.1-2.4,9.9-2.4c3.7,0,6.9,0.8,9.7,2.5c2.7,1.6,4.9,3.9,6.4,6.8
c1.5,2.9,2.3,6.3,2.3,10.1v3.3h-27.4c0.1,2.6,1.1,4.7,2.9,6.3c1.8,1.6,4.1,2.4,6.7,2.4c2.7,0,4.7-0.6,5.9-1.7
c1.3-1.2,2.2-2.5,2.9-3.9l7.8,4.1c-0.7,1.3-1.7,2.8-3.1,4.3c-1.3,1.5-3.1,2.8-5.3,4C283.6,60.5,280.8,61,277.4,61z M268.2,36.8h17.6
c-0.2-2.2-1.1-3.9-2.7-5.2c-1.5-1.3-3.5-2-6-2c-2.6,0-4.6,0.7-6.2,2C269.5,32.9,268.5,34.6,268.2,36.8z"/>
<path class="st1" d="M192.9,60V6.8h18.6l9.2,46.4h1.4l9.2-46.4h18.6V60h-9.7V14.1h-1.4L229.6,60h-16.6L204,14.1h-1.4V60H192.9z"/>
<path class="st1" d="M146.3,60V22.3h9.4v4.9h1.4c0.6-1.3,1.7-2.6,3.4-3.7c1.7-1.2,4.2-1.8,7.6-1.8c2.9,0,5.5,0.7,7.7,2.1
c2.2,1.3,4,3.2,5.2,5.5c1.2,2.3,1.8,5.1,1.8,8.2V60h-9.6V38.2c0-2.8-0.7-5-2.1-6.4c-1.4-1.4-3.3-2.1-5.9-2.1c-2.9,0-5.2,1-6.8,3
c-1.6,1.9-2.4,4.6-2.4,8.1V60H146.3z"/>
<path class="st1" d="M126.1,60V22.3h9.6V60H126.1z M130.9,17.9c-1.7,0-3.2-0.6-4.4-1.7c-1.2-1.1-1.7-2.6-1.7-4.4
c0-1.8,0.6-3.3,1.7-4.4c1.2-1.1,2.7-1.7,4.4-1.7c1.8,0,3.2,0.6,4.4,1.7c1.2,1.1,1.7,2.6,1.7,4.4c0,1.8-0.6,3.3-1.7,4.4
C134.2,17.3,132.7,17.9,130.9,17.9z"/>
<path class="st1" d="M79.9,60V6.8h21.9c3.3,0,6.3,0.7,8.8,2.1c2.6,1.3,4.6,3.2,6,5.6c1.5,2.4,2.2,5.3,2.2,8.7v1.1
c0,3.3-0.8,6.2-2.3,8.7c-1.5,2.4-3.5,4.3-6.1,5.7c-2.5,1.3-5.4,2-8.7,2H89.9V60H79.9z M89.9,31.4h10.9c2.4,0,4.3-0.7,5.8-2
c1.5-1.3,2.2-3.1,2.2-5.4v-0.8c0-2.3-0.7-4.1-2.2-5.4c-1.5-1.3-3.4-2-5.8-2H89.9V31.4z"/>
<path class="st2" d="M285.3,112V91h13.5v3.6h-9.5v5h8.7v3.6h-8.7v5.2h9.7v3.6H285.3z"/>
<path class="st2" d="M268.7,112V91h13.5v3.6h-9.5v5h8.7v3.6h-8.7v5.2h9.7v3.6H268.7z"/>
<path class="st2" d="M249.7,112V91h9.1c1.3,0,2.5,0.2,3.4,0.7c1,0.5,1.7,1.1,2.3,1.9c0.5,0.8,0.8,1.8,0.8,3v0.4
c0,1.3-0.3,2.3-0.9,3.1c-0.6,0.8-1.3,1.4-2.2,1.7v0.5c0.8,0,1.4,0.3,1.9,0.8c0.4,0.5,0.7,1.2,0.7,2v6.9h-4v-6.3
c0-0.5-0.1-0.9-0.4-1.2c-0.2-0.3-0.6-0.4-1.2-0.4h-5.5v7.9H249.7z M253.7,100.4h4.7c0.9,0,1.7-0.2,2.2-0.8c0.5-0.5,0.8-1.2,0.8-2
v-0.3c0-0.8-0.3-1.5-0.8-2c-0.5-0.5-1.3-0.8-2.2-0.8h-4.7V100.4z"/>
<path class="st2" d="M233.7,112V91h13.2v3.6h-9.2v5.1h8.5v3.6h-8.5v8.7H233.7z"/>
<path class="st1" d="M214.3,112V97.1h3.7v1.7h0.5c0.2-0.6,0.6-1,1.1-1.3c0.5-0.3,1.1-0.4,1.8-0.4h1.8v3.4h-1.9c-1,0-1.8,0.3-2.4,0.8
c-0.6,0.5-0.9,1.3-0.9,2.3v8.5H214.3z"/>
<path class="st1" d="M203,112.4c-1.5,0-2.8-0.3-4-0.9c-1.2-0.6-2.1-1.5-2.8-2.6c-0.7-1.1-1-2.5-1-4.1v-0.5c0-1.6,0.3-3,1-4.1
c0.7-1.1,1.6-2,2.8-2.6c1.2-0.6,2.5-0.9,4-0.9c1.5,0,2.8,0.3,4,0.9c1.2,0.6,2.1,1.5,2.8,2.6c0.7,1.1,1,2.5,1,4.1v0.5
c0,1.6-0.3,3-1,4.1c-0.7,1.1-1.6,2-2.8,2.6C205.8,112.1,204.5,112.4,203,112.4z M203,109c1.2,0,2.1-0.4,2.9-1.1
c0.8-0.8,1.1-1.8,1.1-3.2v-0.3c0-1.4-0.4-2.5-1.1-3.2c-0.7-0.8-1.7-1.1-2.9-1.1c-1.2,0-2.1,0.4-2.9,1.1c-0.8,0.7-1.1,1.8-1.1,3.2
v0.3c0,1.4,0.4,2.5,1.1,3.2C200.9,108.7,201.8,109,203,109z"/>
<path class="st1" d="M185.8,112v-11.8H182v-3.1h3.8v-2.8c0-1,0.3-1.8,0.9-2.4c0.6-0.6,1.4-0.9,2.4-0.9h3.9v3.1h-2.6
c-0.6,0-0.8,0.3-0.8,0.9v2.1h3.9v3.1h-3.9V112H185.8z"/>
<path class="st1" d="M155.9,104.6v-0.5c0-1.6,0.3-2.9,0.9-4c0.6-1.1,1.4-2,2.5-2.5c1-0.6,2.2-0.9,3.4-0.9c1.4,0,2.4,0.2,3.1,0.7
c0.7,0.5,1.2,1,1.5,1.5h0.5v-1.8h3.7v17.5c0,1-0.3,1.8-0.9,2.4c-0.6,0.6-1.4,0.9-2.4,0.9h-10v-3.3h8.6c0.6,0,0.8-0.3,0.8-0.9v-3.9
h-0.5c-0.2,0.3-0.5,0.7-0.8,1c-0.4,0.3-0.8,0.6-1.4,0.8c-0.6,0.2-1.4,0.3-2.3,0.3c-1.2,0-2.3-0.3-3.4-0.9c-1-0.6-1.8-1.4-2.5-2.6
C156.2,107.5,155.9,106.1,155.9,104.6z M163.7,108.7c1.2,0,2.1-0.4,2.9-1.1s1.2-1.8,1.2-3.1v-0.3c0-1.4-0.4-2.4-1.2-3.1
c-0.8-0.7-1.7-1.1-2.9-1.1c-1.2,0-2.1,0.4-2.9,1.1c-0.8,0.7-1.2,1.8-1.2,3.1v0.3c0,1.3,0.4,2.4,1.2,3.1S162.6,108.7,163.7,108.7z"/>
<path class="st1" d="M145.3,112.4c-1.5,0-2.8-0.3-4-0.9c-1.2-0.6-2.1-1.5-2.8-2.6s-1-2.5-1-4.1v-0.5c0-1.6,0.3-3,1-4.1
c0.7-1.1,1.6-2,2.8-2.6c1.2-0.6,2.5-0.9,4-0.9s2.8,0.3,4,0.9c1.2,0.6,2.1,1.5,2.8,2.6c0.7,1.1,1,2.5,1,4.1v0.5c0,1.6-0.3,3-1,4.1
c-0.7,1.1-1.6,2-2.8,2.6C148.1,112.1,146.8,112.4,145.3,112.4z M145.3,109c1.2,0,2.1-0.4,2.9-1.1c0.8-0.8,1.1-1.8,1.1-3.2v-0.3
c0-1.4-0.4-2.5-1.1-3.2c-0.7-0.8-1.7-1.1-2.9-1.1c-1.2,0-2.1,0.4-2.9,1.1c-0.8,0.7-1.1,1.8-1.1,3.2v0.3c0,1.4,0.4,2.5,1.1,3.2
C143.2,108.7,144.1,109,145.3,109z"/>
<path class="st1" d="M130.3,112V91h3.8v21H130.3z"/>
<path class="st1" d="M109.6,112v-3.5h2.8v-14h-2.8V91h10.8c1.3,0,2.4,0.2,3.3,0.7c1,0.4,1.7,1,2.2,1.8c0.5,0.8,0.8,1.7,0.8,2.8v0.3
c0,1-0.2,1.8-0.5,2.4c-0.4,0.6-0.8,1.1-1.3,1.4c-0.5,0.3-0.9,0.6-1.4,0.7v0.5c0.4,0.1,0.9,0.3,1.4,0.7c0.5,0.3,1,0.8,1.3,1.4
c0.4,0.6,0.6,1.4,0.6,2.4v0.3c0,1.2-0.3,2.2-0.8,3c-0.5,0.8-1.3,1.4-2.2,1.9c-0.9,0.4-2,0.7-3.3,0.7H109.6z M116.3,108.4h3.7
c0.9,0,1.6-0.2,2.1-0.6c0.5-0.4,0.8-1,0.8-1.8v-0.3c0-0.8-0.3-1.4-0.8-1.8c-0.5-0.4-1.2-0.6-2.1-0.6h-3.7V108.4z M116.3,99.6h3.7
c0.8,0,1.5-0.2,2-0.6c0.5-0.4,0.8-1,0.8-1.7v-0.3c0-0.8-0.3-1.3-0.8-1.7c-0.5-0.4-1.2-0.6-2-0.6h-3.7V99.6z"/>
<path class="st1" d="M85.9,118v-3.3H94c0.6,0,0.8-0.3,0.8-0.9V110h-0.5c-0.2,0.3-0.4,0.7-0.8,1c-0.3,0.3-0.8,0.6-1.4,0.8
c-0.6,0.2-1.3,0.3-2.2,0.3c-1.2,0-2.2-0.3-3.1-0.8c-0.9-0.5-1.5-1.3-2-2.2c-0.5-0.9-0.7-2-0.7-3.2v-8.9h3.8v8.6c0,1.1,0.3,2,0.8,2.5
c0.6,0.6,1.4,0.8,2.4,0.8c1.2,0,2.1-0.4,2.7-1.1c0.6-0.8,1-1.9,1-3.2v-7.6h3.8v17.5c0,1-0.3,1.8-0.9,2.4c-0.6,0.6-1.4,0.9-2.4,0.9
H85.9z"/>
<path class="st1" d="M72.9,112.4c-1.5,0-2.8-0.3-4-0.9s-2.1-1.5-2.8-2.6s-1-2.5-1-4.1v-0.5c0-1.6,0.3-3,1-4.1c0.7-1.1,1.6-2,2.8-2.6
s2.5-0.9,4-0.9c1.5,0,2.8,0.3,4,0.9s2.1,1.5,2.8,2.6c0.7,1.1,1,2.5,1,4.1v0.5c0,1.6-0.3,3-1,4.1s-1.6,2-2.8,2.6
S74.4,112.4,72.9,112.4z M72.9,109c1.2,0,2.1-0.4,2.9-1.1c0.8-0.8,1.1-1.8,1.1-3.2v-0.3c0-1.4-0.4-2.5-1.1-3.2
c-0.7-0.8-1.7-1.1-2.9-1.1c-1.2,0-2.1,0.4-2.9,1.1c-0.8,0.7-1.1,1.8-1.1,3.2v0.3c0,1.4,0.4,2.5,1.1,3.2
C70.8,108.7,71.8,109,72.9,109z"/>
<path class="st1" d="M57.9,112V91h3.8v21H57.9z"/>
<path class="st1" d="M38.8,118V97.1h3.7v1.8H43c0.3-0.6,0.9-1.1,1.6-1.5c0.7-0.5,1.8-0.7,3.1-0.7c1.2,0,2.3,0.3,3.3,0.9
c1,0.6,1.8,1.4,2.5,2.6c0.6,1.1,0.9,2.5,0.9,4.1v0.5c0,1.6-0.3,3-0.9,4.1c-0.6,1.1-1.4,2-2.5,2.6c-1,0.6-2.1,0.9-3.3,0.9
c-0.9,0-1.7-0.1-2.3-0.3c-0.6-0.2-1.1-0.5-1.5-0.8c-0.4-0.3-0.7-0.7-0.9-1h-0.5v7.7H38.8z M46.6,109.1c1.2,0,2.1-0.4,2.9-1.1
c0.8-0.8,1.2-1.9,1.2-3.3v-0.3c0-1.4-0.4-2.5-1.2-3.3c-0.8-0.8-1.8-1.1-2.9-1.1s-2.1,0.4-2.9,1.1c-0.8,0.7-1.2,1.8-1.2,3.3v0.3
c0,1.4,0.4,2.5,1.2,3.3C44.4,108.7,45.4,109.1,46.6,109.1z"/>
<path class="st1" d="M28.2,112.4c-1.5,0-2.8-0.3-3.9-0.9c-1.1-0.6-2-1.5-2.6-2.7c-0.6-1.2-0.9-2.5-0.9-4.1v-0.4
c0-1.6,0.3-2.9,0.9-4.1c0.6-1.2,1.5-2,2.6-2.7c1.1-0.6,2.4-1,3.9-1c1.5,0,2.7,0.3,3.8,1c1.1,0.6,1.9,1.5,2.5,2.7
c0.6,1.1,0.9,2.5,0.9,4v1.3H24.6c0,1,0.4,1.8,1.1,2.5c0.7,0.6,1.6,1,2.6,1c1.1,0,1.8-0.2,2.3-0.7s0.9-1,1.1-1.5l3.1,1.6
c-0.3,0.5-0.7,1.1-1.2,1.7c-0.5,0.6-1.2,1.1-2.1,1.6C30.7,112.2,29.6,112.4,28.2,112.4z M24.6,102.8h7c-0.1-0.9-0.4-1.6-1-2.1
c-0.6-0.5-1.4-0.8-2.4-0.8c-1,0-1.8,0.3-2.4,0.8C25.1,101.3,24.7,102,24.6,102.8z"/>
<path class="st1" d="M0.8,112v-3.5h2.8v-14H0.8V91h8.6c2.8,0,5,0.7,6.4,2.2c1.5,1.4,2.2,3.5,2.2,6.4v4c0,2.8-0.7,4.9-2.2,6.4
c-1.5,1.4-3.6,2.1-6.4,2.1H0.8z M7.5,108.4h2c1.6,0,2.8-0.4,3.5-1.3c0.7-0.8,1.1-2,1.1-3.5v-4.2c0-1.5-0.4-2.7-1.1-3.5
c-0.7-0.8-1.9-1.3-3.5-1.3h-2V108.4z"/>
</svg>

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@@ -32,13 +32,13 @@ content/
And these templates:
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with .Prev }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}

View File

@@ -32,13 +32,13 @@ content/
And these templates:
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with .PrevInSection }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}

View File

@@ -32,13 +32,13 @@ content/
And these templates:
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ $pages := .CurrentSection.Pages.ByWeight }}
{{ with $pages.Prev . }}
@@ -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:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ $pages := .CurrentSection.Pages.ByWeight.Reverse }}
{{ with $pages.Prev . }}

View File

@@ -34,7 +34,7 @@ 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:
```go-html-template {file="layouts/_default/taxonomy.html"}
```go-html-template {file="layouts/taxonomy.html"}
{{ $taxonomyObject := .Data.Terms }}
```

View File

@@ -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:
```go-html-template {file="layouts/shortcodes/include.html" copy=true}
```go-html-template {file="layouts/_shortcodes/include.html" copy=true}
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}

View File

@@ -84,7 +84,7 @@ disableKinds
: (`[]string`) A slice of page [kinds](g) to disable during the build process, any of `404`, `home`, `page`, `robotstxt`, `rss`, `section`, `sitemap`, `taxonomy`, or `term`.
disableLanguages
: (`[]string]`) A slice of language keys representing the languages to disable during the build process. Although this is functional, consider using the [`disabled`] key under each language instead.
: (`[]string`) A slice of language keys representing the languages to disable during the build process. Although this is functional, consider using the [`disabled`] key under each language instead.
disableLiveReload
: (`bool`) Whether to disable automatic live reloading of the browser window. Default is `false`.
@@ -123,7 +123,7 @@ ignoreCache
: (`bool`) Whether to ignore the cache directory. Default is `false`.
ignoreFiles
: (`[]string]`) A slice of [regular expressions](g) used to exclude specific files from a build. These expressions are matched against the absolute file path and apply to files within the `content`, `data`, and `i18n` directories. For more advanced file exclusion options, see the section on [module mounts].
: (`[]string`) A slice of [regular expressions](g) used to exclude specific files from a build. These expressions are matched against the absolute file path and apply to files within the `content`, `data`, and `i18n` directories. For more advanced file exclusion options, see the section on [module mounts].
ignoreLogs
: (`[]string`) A slice of message identifiers corresponding to warnings and errors you wish to suppress. See [`erroridf`] and [`warnidf`].
@@ -280,7 +280,7 @@ themesDir
: (`string`) The designated directory for themes. Default is `themes`.
timeout
: (`string`) The timeout for generating page content, either as a [duration] or in seconds. This timeout is used to prevent infinite recursion during content generation. You may need to increase this value if your pages take a long time to generate, for example, due to extensive image processing or reliance on remote content. Default is `30s`.
: (`string`) The timeout for generating page content, either as a [duration] or in seconds. This timeout is used to prevent infinite recursion during content generation. You may need to increase this value if your pages take a long time to generate, for example, due to extensive image processing or reliance on remote content. Default is `60s`.
timeZone
: (`string`) The time zone used to parse dates without time zone offsets, including front matter date fields and values passed to the [`time.AsTime`] and [`time.Format`] template functions. The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone Database]. For example, `America/Los_Angeles` and `Europe/Oslo` are valid time zones.

View File

@@ -79,6 +79,11 @@ my-project/
The root configuration keys are {{< root-configuration-keys >}}.
> [!note]
> You must define `cascade` tables in the root configuration file. You cannot define `cascade` tables in a dedicated file. See issue [#12899] for details.
[#12899]: https://github.com/gohugoio/hugo/issues/12899
### Omit the root key
When splitting the configuration by root key, omit the root key in the component file. For example, these are equivalent:

View File

@@ -247,7 +247,7 @@ rougify style monokai.sublime > assets/css/syntax.css
In your base template add a link to the CSS file:
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
<head>
...
{{ with resources.Get "css/syntax.css" }}
@@ -337,5 +337,5 @@ ordered
[superscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
[AsciiDoc]: https://asciidoc.org/
[Emacs Org Mode]: https://orgmode.org/
[Pandoc]: https://www.pandoc.org/
[Pandoc]: https://pandoc.org/
[reStructuredText]: https://docutils.sourceforge.io/rst.html

View File

@@ -135,7 +135,7 @@ See [configure outputs] for more information.
Create a template to render the output format. Since Atom feeds are lists, you need to create a list template. Consult the [template lookup order] to find the correct template path:
```text
layouts/_default/list.atom.atom
layouts/list.atom.atom
```
We leave writing the template code as an exercise for you. Aim for a result similar to the [embedded RSS template].
@@ -154,7 +154,7 @@ To access output formats, each `Page` object provides two methods: [`OutputForma
By default, a `Page` object's [`Permalink`] and [`RelPermalink`] methods return the URL of the [primary output format](g), typically `html`. This behavior remains consistent regardless of the template used.
For example, in `single.json.json`, you'll see:
For example, in `page.json.json`, you'll see:
```go-html-template
{{ .RelPermalink }} → /that-page/
@@ -165,7 +165,7 @@ For example, in `single.json.json`, you'll see:
To make these methods return the URL of the _current_ template's output format, you must set the [`permalinkable`] setting to `true` for that format.
With `permalinkable` set to true for `json` in the same `single.json.json` template:
With `permalinkable` set to true for `json` in the same `page.json.json` template:
```go-html-template
{{ .RelPermalink }} → /that-page/index.json
@@ -188,9 +188,9 @@ For example, for section pages:
Output format|Template path
:--|:--
`html`|`layouts/_default/section.html.html`
`json`|`layouts/_default/section.json.json`
`rss`|`layouts/_default/section.rss.xml`
`html`|`layouts/section.html.html`
`json`|`layouts/section.json.json`
`rss`|`layouts/section.rss.xml`
[`AlternativeOutputFormats`]: /methods/page/alternativeoutputformats/
[`OutputFormats`]: /methods/page/outputformats/

View File

@@ -97,7 +97,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:
```go-html-template {file="layouts/partials/related.html" copy=true}
```go-html-template {file="layouts/_partials/related.html" copy=true}
{{ with site.RegularPages.Related . | first 5 }}
<p>Related content:</p>
<ul>

View File

@@ -58,7 +58,7 @@ taxonomies:
To disable the taxonomy system, use the [`disableKinds`] setting in the root of your site configuration to disable the `taxonomy` and `term` page [kinds](g).
{{< code-toggle file=hugo >}}
disableKinds = ['categories','tags']
disableKinds = ['taxonomy','term']
{{< /code-toggle >}}
[`disableKinds`]: /configuration/all/#disablekinds

View File

@@ -69,7 +69,7 @@ title = 'Headless page'
To include the content and images on the home page:
```go-html-template {file="layouts/_default/home.html"}
```go-html-template {file="layouts/home.html"}
{{ with .Site.GetPage "/headless" }}
{{ .Content }}
{{ range .Resources.ByType "image" }}
@@ -127,7 +127,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:
```go-html-template {file="layouts/_default/home.html"}
```go-html-template {file="layouts/home.html"}
{{ with .Site.GetPage "/headless" }}
{{ range .Pages }}
{{ .Content }}
@@ -186,7 +186,7 @@ render = 'always'
To render the glossary:
```go-html-template {file="layouts/glossary/list.html"}
```go-html-template {file="layouts/glossary/section.html"}
<dl>
{{ range .Pages }}
<dt>{{ .Title }}</dt>

View File

@@ -34,7 +34,7 @@ For many websites, this is enough configuration. However, you also have the opti
Disqus has its own [internal template](/templates/embedded/#disqus) available, to render it add the following code where you want comments to appear:
```go-html-template
{{ template "_internal/disqus.html" . }}
{{ partial "disqus.html" . }}
```
## Alternatives

View File

@@ -27,7 +27,7 @@ content/
└── _index.md
```
Each content adapter is named _content.gotmpl and uses the same [syntax] as templates in the `layouts` directory. You can use any of the [template functions] within a content adapter, as well as the methods described below.
Each content adapter is named `_content.gotmpl` and uses the same [syntax] as templates in the `layouts` directory. You can use any of the [template functions] within a content adapter, as well as the methods described below.
## Methods
@@ -71,7 +71,7 @@ Adds a page resource to the site.
Then retrieve the new page resource with something like:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with .Resources.Get "cover.jpg" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
@@ -90,7 +90,7 @@ Returns the `Site` to which the pages will be added.
### Store
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/).
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/).
```go-html-template {file="content/books/_content.gotmpl"}
{{ .Store.Set "key" "value" }}
@@ -99,7 +99,7 @@ Returns a persistent “scratch pad” to store and manipulate data. The main us
### 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.
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.
```go-html-template {file="content/books/_content.gotmpl"}
{{ .EnableAllLanguages }}
@@ -153,7 +153,7 @@ Key|Description|Required
`title`|The resource title.|&nbsp;
> [!note]
> If the `content.value` is a string Hugo creates a new resource. If the `content.value` is a resource, Hugo obtains the value from the existing resource.
> When `content.value` is a string, Hugo generates a new resource with a publication path relative to the page. However, if `content.value` is already a resource, Hugo directly uses its value and publishes it relative to the site root. This latter method is more efficient.
>
> When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C/cover.jpg` produces a logical path of `/section/a-b-c/cover.jpg`.
@@ -237,9 +237,9 @@ Create the content adapter.
### Step 4
Create a single template to render each book review.
Create a page template to render each book review.
```go-html-template {file="layouts/books/single.html" copy=true}
```go-html-template {file="layouts/books/page.html" copy=true}
{{ define "main" }}
<h1>{{ .Title }}</h1>
@@ -338,7 +338,7 @@ content/
└── the-hunchback-of-notre-dame.md
```
If the content adapter also creates books/the-hunchback-of-notre-dame, the content of the published page is indeterminate. You can not define the processing order.
If the content adapter also creates `books/the-hunchback-of-notre-dame`, the content of the published page is indeterminate. You can not define the processing order.
To detect page collisions, use the `--printPathWarnings` flag when building your site.

View File

@@ -65,7 +65,7 @@ Use data sources to augment existing content. For example, create a shortcode to
{{</* csv-to-table "pets.csv" */>}}
```
```go-html-template {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 }}

View File

@@ -39,7 +39,7 @@ Will be rendered as:
Hugo does not provide a built-in template for Mermaid diagrams. Create your own using a [code block render hook]:
```go-html-template {file="layouts/_default/_markup/render-codeblock-mermaid.html" copy=true}
```go-html-template {file="layouts/_markup/render-codeblock-mermaid.html" copy=true}
<pre class="mermaid">
{{ .Inner | htmlEscape | safeHTML }}
</pre>
@@ -48,7 +48,7 @@ Hugo does not provide a built-in template for Mermaid diagrams. Create your own
Then include this snippet at the _bottom_ of your base template, before the closing `body` tag:
```go-html-template {file="layouts/_default/baseof.html" copy=true}
```go-html-template {file="layouts/baseof.html" copy=true}
{{ if .Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';

View File

@@ -75,7 +75,7 @@ Create your content in the [Emacs Org Mode] format preceded by front matter. You
### AsciiDoc
Create your content in the [AsciiDoc] format preceded by front matter. Hugo renders AsciiDoc content to HTML using the Asciidoctor executable. You must install Asciidoctor and its dependencies (Ruby) to use the AsciiDoc content format.
Create your content in the [AsciiDoc] format preceded by front matter. Hugo renders AsciiDoc content to HTML using the Asciidoctor executable. You must install Asciidoctor and its dependencies (Ruby) to render the AsciiDoc content format.
You can configure the AsciiDoc renderer in your [site configuration][configure asciidoc].
@@ -97,7 +97,9 @@ hugo --logLevel info
### Pandoc
Create your content in the [Pandoc] format preceded by front matter. Hugo renders Pandoc content to HTML using the Pandoc executable. You must install Pandoc to use the Pandoc content format.
Create your content in the [Pandoc] format[^1] preceded by front matter. Hugo renders Pandoc content to HTML using the Pandoc executable. You must install Pandoc to render the Pandoc content format.
[^1]: This is a derivation of the Markdown format as described by the CommonMark specification.
Hugo passes these CLI flags when calling the Pandoc executable:
@@ -105,11 +107,11 @@ Hugo passes these CLI flags when calling the Pandoc executable:
--mathjax
```
[Pandoc]: https://pandoc.org/
[Pandoc]: https://pandoc.org/MANUAL.html#pandocs-markdown
### reStructuredText
Create your content in the [reStructuredText] format preceded by front matter. Hugo renders reStructuredText content to HTML using [Docutils], specifically rst2html. You must install Docutils and its dependencies (Python) to use the reStructuredText content format.
Create your content in the [reStructuredText] format preceded by front matter. Hugo renders reStructuredText content to HTML using [Docutils], specifically rst2html. You must install Docutils and its dependencies (Python) to render the reStructuredText content format.
Hugo passes these CLI flags when calling the rst2html executable:

View File

@@ -237,7 +237,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:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with .GetTerms "tags" }}
<p>Tags</p>
<ul>

View File

@@ -64,7 +64,7 @@ math = true
The configuration above enables mathematical rendering on every page unless you set the `math` parameter to `false` in front matter. To enable mathematical rendering as needed, set the `math` parameter to `false` in your site configuration, and set the `math` parameter to `true` in front matter. Use this parameter in your base template as shown in [Step 3].
> [!note]
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you will need to double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you must double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
>
> See the [inline delimiters](#inline-delimiters) section for details.
@@ -87,7 +87,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.
```go-html-template {file="layouts/partials/math.html" copy=true}
```go-html-template {file="layouts/_partials/math.html" copy=true}
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script>
MathJax = {
@@ -108,7 +108,7 @@ The delimiters above must match the delimiters in your site configuration.
Conditionally call the partial template from the base template.
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
<head>
...
{{ if .Param "math" }}
@@ -161,10 +161,10 @@ math = true
The configuration, JavaScript, and examples above use the `\(...\)` delimiter pair for inline equations. The `$...$` delimiter pair is a common alternative, but using it may result in unintended formatting if you use the `$` symbol outside of math contexts.
If you add the `$...$` delimiter pair to your configuration and JavaScript, you must double-escape the `$` when outside of math contexts, regardless of whether mathematical rendering is enabled on the page. For example:
If you add the `$...$` delimiter pair to your configuration and JavaScript, you must double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting. For example:
```text
A \\$5 bill _saved_ is a \\$5 bill _earned_.
I will give you \\$2 if you can solve $y = x^2$.
```
> [!note]
@@ -181,7 +181,7 @@ MathJax and KaTeX are open-source JavaScript display engines. Both engines are f
To use KaTeX instead of MathJax, replace the partial template from [Step 2] with this:
```go-html-template {file="layouts/partials/math.html" copy=true}
```go-html-template {file="layouts/_partials/math.html" copy=true}
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css"

View File

@@ -114,7 +114,7 @@ If, across the linked bundles, two or more files share the same basename, only o
To create a list of links to translated content, use a template similar to the following:
```go-html-template {file="layouts/partials/i18nlist.html"}
```go-html-template {file="layouts/_partials/i18nlist.html"}
{{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4>
<ul>
@@ -127,7 +127,7 @@ To create a list of links to translated content, use a template similar to the f
{{ end }}
```
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.
The above can be put in a partial template then included in any template. It will not print anything if there are no translations for a given page.
The above also uses the [`i18n` function][i18func] described in the next section.
@@ -135,7 +135,7 @@ 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:
```go-html-template {file="layouts/partials/allLanguages.html"}
```go-html-template {file="layouts/_partials/allLanguages.html"}
<ul>
{{ range $.Site.Home.AllTranslations }}
<li><a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>

View File

@@ -99,7 +99,7 @@ The [sections] can be nested as deeply as you want. The important thing to under
### Single pages in sections
Single content files in each of your sections will be rendered by a [single template]. Here is an example of a single `post` within `posts`:
Single content files in each of your sections will be rendered by a [page template]. Here is an example of a single `post` within `posts`:
```txt
path ("posts/my-first-hugo-post.md")
@@ -148,4 +148,4 @@ The `url` is the entire URL path, defined by the file path and optionally overri
[config]: /configuration/
[pretty]: /content-management/urls/#appearance
[sections]: /content-management/sections/
[single template]: /templates/types/#single
[page template]: /templates/types/#page

View File

@@ -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:
```go-html-template {file="layouts/partials/related.html" copy=true}
```go-html-template {file="layouts/_partials/related.html" copy=true}
{{ with site.RegularPages.Related . | first 5 }}
<p>Related content:</p>
<ul>

View File

@@ -63,7 +63,7 @@ With the file structure from the [example above](#overview):
1. The list page for the articles section includes all articles, regardless of directory structure; none of the subdirectories are sections.
1. The articles/2022 and articles/2023 directories do not have list pages; they are not sections.
1. The list page for the products section, by default, includes product-1 and product-2, but not their descendant pages. To include descendant pages, use the `RegularPagesRecursive` method instead of the `Pages` method in the list template.
1. The list page for the products section, by default, includes product-1 and product-2, but not their descendant pages. To include descendant pages, use the `RegularPagesRecursive` method instead of the `Pages` method in the section template.
1. All directories in the products section have list pages; each directory is a section.
## Template selection
@@ -74,15 +74,15 @@ With the file structure from the [example above](#overview):
Content directory|Section template
:--|:--
`content/products`|`layouts/products/list.html`
`content/products/product-1`|`layouts/products/list.html`
`content/products/product-1/benefits`|`layouts/products/list.html`
`content/products`|`layouts/products/section.html`
`content/products/product-1`|`layouts/products/section.html`
`content/products/product-1/benefits`|`layouts/products/section.html`
Content directory|Single template
Content directory|Page template
:--|:--
`content/products`|`layouts/products/single.html`
`content/products/product-1`|`layouts/products/single.html`
`content/products/product-1/benefits`|`layouts/products/single.html`
`content/products`|`layouts/products/page.html`
`content/products/product-1`|`layouts/products/page.html`
`content/products/product-1/benefits`|`layouts/products/page.html`
If you need to use a different template for a subsection, specify `type` and/or `layout` in front matter.
@@ -98,7 +98,7 @@ The content file (benefit-1.md) has four ancestors: benefits, product-1, product
For example, use the `.Ancestors` method to render breadcrumb navigation.
```go-html-template {file="layouts/partials/breadcrumb.html"}
```go-html-template {file="layouts/_partials/breadcrumb.html"}
<nav aria-label="breadcrumb" class="breadcrumb">
<ol>
{{ range .Ancestors.Reverse }}

View File

@@ -22,7 +22,7 @@ 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):
```go-html-template {file="layouts/shortcodes/audio.html"}
```go-html-template {file="layouts/_shortcodes/audio.html"}
{{ with resources.Get (.Get "src") }}
<audio controls preload="auto" src="{{ .RelPermalink }}"></audio>
{{ end }}
@@ -181,7 +181,7 @@ With standard notation, Hugo processes the shortcode separately, merging the out
By way of example, with this shortcode template:
```go-html-template {file="layouts/shortcodes/foo.html"}
```go-html-template {file="layouts/_shortcodes/foo.html"}
{{ .Inner }}
```

View File

@@ -108,18 +108,73 @@ categories_weight = 44
By using taxonomic weight, the same piece of content can appear in different positions in different taxonomies.
## Add custom metadata to a taxonomy or term
## Metadata
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
Display metadata about each term by creating a corresponding branch bundle in the `content` directory.
{{< code-toggle file=content/actors/bruce-willis/_index.md fm=true >}}
title: "Bruce Willis"
wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
For example, create an "authors" taxonomy:
{{< code-toggle file=hugo >}}
[taxonomies]
author = 'authors'
{{< /code-toggle >}}
[content section]: /content-management/sections/
[content type]: /content-management/types/
[documentation on archetypes]: /content-management/archetypes/
[front matter]: /content-management/front-matter/
[taxonomy templates]: /templates/types/#taxonomy
[site configuration]: /configuration/
Then create content with one [branch bundle](g) for each term:
```text
content/
└── authors/
├── jsmith/
│ ├── _index.md
│ └── portrait.jpg
└── rjones/
├── _index.md
└── portrait.jpg
```
Then add front matter to each term page:
{{< code-toggle file=content/authors/jsmith/_index.md fm=true >}}
title = "John Smith"
affiliation = "University of Chicago"
{{< /code-toggle >}}
Then create a taxonomy template specific to the "authors" taxonomy:
```go-html-template {file="layouts/authors/taxonomy.html"}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Data.Terms.Alphabetical }}
<h2><a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a></h2>
<p>Affiliation: {{ .Page.Params.Affiliation }}</p>
{{ with .Page.Resources.Get "portrait.jpg" }}
{{ with .Fill "100x100" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="portrait">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
```
In the example above we list each author including their affiliation and portrait.
Or create a term template specific to the "authors" taxonomy:
```go-html-template {file="layouts/authors/term.html"}
{{ define "main" }}
<h1>{{ .Title }}</h1>
<p>Affiliation: {{ .Params.affiliation }}</p>
{{ with .Resources.Get "portrait.jpg" }}
{{ with .Fill "100x100" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="portrait">
{{ end }}
{{ end }}
{{ .Content }}
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ end }}
```
In the example above we display the author including their affiliation and portrait, then a list of associated content.

View File

@@ -1,14 +0,0 @@
---
title: Content types
description: Hugo is built around content organized in sections.
categories: []
keywords: []
aliases: [/content/types]
---
A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` is set.
A content type is used to
- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](/templates/content-view) for more.
- Determine which [archetype](/content-management/archetypes/) template to use for new content.

View File

@@ -108,7 +108,7 @@ multilingual|`about`|`https://example.org/de/about/`
{{< new-in 0.131.0 />}}
You can also usetokens when setting the `url` value. This is typically used in `cascade` sections:
You can also use tokens when setting the `url` value. This is typically used in `cascade` sections:
{{< code-toggle file=content/foo/bar/_index.md fm=true >}}
title ="Bar"

View File

@@ -153,7 +153,7 @@ CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest
To build and install a specific release:
```sh
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.144.2
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.147.1
```
To build and install at the latest commit on the master branch:

View File

@@ -152,26 +152,27 @@ This example demonstrates the minimum required front matter fields.
If quotation marks are required, prefer single quotes to double quotes when possible.
Seq|Field|Description|Required
--:|:--|:--|:--
1|`title`|The page title|:heavy_check_mark:|
2|`linkTitle`|A short version of the page title||
3|`description`|A complete sentence describing the page|:heavy_check_mark:|
4|`categories`|An array of terms in the categories taxonomy|:heavy_check_mark: [^1]|
5|`keywords`|An array of keywords used to identify related content|:heavy_check_mark: [^1]|
6|`publishDate`|Applicable to news items: the publication date||
7|`params.altTitle`|An alternate title: used in the "see also" panel if provided||
8|`params.functions_and_methods.aliases`|Applicable to function and method pages: an array of alias names||
9|`params.functions_and_methods.returnType`|Applicable to function and method pages: the data type returned||
10|`params.functions_and_methods.signatures`|Applicable to function and method pages: an array of signatures||
11|`params.hide_in_this_section`|Whether to hide the "in this section" panel||
12|`params.minversion`|Applicable to the quick start page: the minimum Hugo version required||
13|`params.permalink`|Reserved for use by the news content adapter||
14|`params.reference (used in glossary term)`|Applicable to glossary entries: a URL for additional information||
15|`params.show_publish_date`|Whether to show the `publishDate` when rendering the page||
16|`weight`|The page weight||
17|`aliases`|Previous URLs used to access this page||
18|`expirydate`|The expiration date||
Field|Description|Required
:--|:--|:--
`title`|The page title|:heavy_check_mark:|
`linkTitle`|A short version of the page title||
`description`|A complete sentence describing the page|:heavy_check_mark:|
`categories`|An array of terms in the categories taxonomy|:heavy_check_mark: [^1]|
`keywords`|An array of keywords used to identify related content|:heavy_check_mark: [^1]|
`publishDate`|Applicable to news items: the publication date||
`params.alt_title`|An alternate title: used in the "see also" panel if provided||
`params.functions_and_methods.aliases`|Applicable to function and method pages: an array of alias names||
`params.functions_and_methods.returnType`|Applicable to function and method pages: the data type returned||
`params.functions_and_methods.signatures`|Applicable to function and method pages: an array of signatures||
`params.hide_in_this_section`|Whether to hide the "in this section" panel||
`params.minversion`|Applicable to the quick start page: the minimum Hugo version required||
`params.permalink`|Reserved for use by the news content adapter||
`params.reference (used in glossary term)`|Applicable to glossary entries: a URL for additional information||
`params.searchable`|Whether to add the content of this page to the search index. The default value is cascaded down from the site configuration; `true` if the page kind is `page`, and `false` if the page kind is one of `home`, `section`, `taxonomy`, or `term`. Add this field to override the default value.||
`params.show_publish_date`|Whether to show the `publishDate` when rendering the page||
`weight`|The page weight||
`aliases`|Previous URLs used to access this page||
`expirydate`|The expiration date||
[^1]: The field is required, but its data is not.
@@ -185,13 +186,13 @@ If the title in the "See also" sidebar is ambiguous or the same as another page,
title = "Long descriptive title"
linkTitle = "Short title"
[params]
altTitle = "Whatever you want"
alt_title = "Whatever you want"
{{< /code-toggle >}}
Use of the alternate title is limited to the "See also" sidebar.
> [!note]
> Think carefully before setting the `altTitle`. Use it only when absolutely necessary.
> Think carefully before setting the `alt_title`. Use it only when absolutely necessary.
## Code examples
@@ -223,10 +224,10 @@ erroneous lexing/highlighting of shortcode calls.
```
````
To include a filename header and copy-to-clipboard button:
To include a file name header and copy-to-clipboard button:
````text
```go-html-template {file="layouts/partials/foo.html" copy=true}
```go-html-template {file="layouts/_partials/foo.html" copy=true}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
@@ -236,7 +237,7 @@ To include a filename header and copy-to-clipboard button:
To wrap the code block within an initially-opened `details` element using a non-default summary:
````text
```go-html-template {details=true open=true summary="layouts/partials/foo.html" copy=true}
```go-html-template {details=true open=true summary="layouts/_partials/foo.html" copy=true}
{{ if eq $foo "bar" }}
{{ print "foo is bar" }}
{{ end }}
@@ -427,7 +428,7 @@ Use the [new-in shortcode](#new-in) to indicate a new feature:
{{</* new-in 0.144.0 */>}}
```
The "new in" label will be hidden if the specified version is older than a predefined threshold, based on differences in major and minor versions. See&nbsp;[details](https://github.com/gohugoio/hugoDocs/blob/master/_vendor/github.com/gohugoio/gohugoioTheme/layouts/shortcodes/new-in.html).
The "new in" label will be hidden if the specified version is older than a predefined threshold, based on differences in major and minor versions. See&nbsp;[details](https://github.com/gohugoio/hugoDocs/blob/master/_vendor/github.com/gohugoio/gohugoioTheme/layouts/_shortcodes/new-in.html).
## Deprecated features
@@ -514,17 +515,17 @@ Visit the [documentation repository] and create a pull request (PR).
A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
[ATX]: https://spec.commonmark.org/0.30/#atx-headings
[ATX]: https://spec.commonmark.org/current/#atx-headings
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[developer documentation style guide]: https://developers.google.com/style
[documentation repository]: https://github.com/gohugoio/hugoDocs/
[fenced code blocks]: https://spec.commonmark.org/0.30/#fenced-code-blocks
[fenced code blocks]: https://spec.commonmark.org/current/#fenced-code-blocks
[glossary]: /quick-reference/glossary/
[indented code blocks]: https://spec.commonmark.org/0.30/#indented-code-blocks
[indented code blocks]: https://spec.commonmark.org/current/#indented-code-blocks
[issues]: https://github.com/gohugoio/hugoDocs/issues
[list items]: https://spec.commonmark.org/0.30/#list-items
[list items]: https://spec.commonmark.org/current/#list-items
[project repository]: https://github.com/gohugoio/hugo
[raw HTML]: https://spec.commonmark.org/0.30/#raw-html
[raw HTML]: https://spec.commonmark.org/current/#raw-html
[related content]: /content-management/related-content/
[setext]: https://spec.commonmark.org/0.30/#setext-heading
[setext]: https://spec.commonmark.org/current/#setext-heading

View File

@@ -3,6 +3,8 @@ title: Hugo Documentation
linkTitle: Docs
description: Hugo is the world's fastest static website engine. It's written in Go (aka Golang) and developed by bep, spf13 and friends.
layout: list
params:
searchable: false
---
<!--

View File

@@ -12,8 +12,18 @@ aliases: [/functions/shuffle]
---
```go-html-template
{{ shuffle (seq 1 2 3) }} → [3 1 2]
{{ shuffle (slice "a" "b" "c") }} → [b a c]
{{ collections.Shuffle (slice "a" "b" "c") }} → [b a c]
```
The result will vary from one build to the next.
To render an unordered list of 5 random pages from a page collection:
```go-html-template
<ul>
{{ $p := site.RegularPages }}
{{ range $p | collections.Shuffle | first 5 }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
```

View File

@@ -66,20 +66,20 @@ vars
```go-html-template {copy=true}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" (not hugo.IsProduction)
"outputStyle" (cond hugo.IsProduction "compressed" "expanded")
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" site.Params.styles
"includePaths" (slice "node_modules/bootstrap/scss")
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsProduction }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ else }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ end }}
{{ end }}
{{ end }}
@@ -113,7 +113,7 @@ macOS|Homebrew|[brew.sh]|`brew install sass/sass/sass`
Windows|Chocolatey|[chocolatey.org]|`choco install sass`
Windows|Scoop|[scoop.sh]|`scoop install sass`
You may also install [prebuilt binaries] for Linux, macOS, and Windows.
You may also install [prebuilt binaries] for Linux, macOS, and Windows. You must install the prebuilt binary outside of your project directory and ensure its path is included in your system's PATH environment variable.
Run `hugo env` to list the active transpilers.
@@ -141,8 +141,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
```yaml
variables:
HUGO_VERSION: 0.144.2
DART_SASS_VERSION: 1.85.0
HUGO_VERSION: 0.147.9
DART_SASS_VERSION: 1.89.2
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
@@ -175,8 +175,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
```toml
[build.environment]
HUGO_VERSION = "0.144.2"
DART_SASS_VERSION = "1.85.0"
HUGO_VERSION = "0.147.9"
DART_SASS_VERSION = "1.89.2"
NODE_VERSION = "22"
TZ = "America/Los_Angeles"

View File

@@ -18,8 +18,10 @@ Use the `css.TailwindCSS` function to process your Tailwind CSS files. This func
1. Compile those utility classes into standard CSS.
1. Generate an optimized CSS output file.
> [!caution]
> Tailwind CSS v4.0 and later requires a relatively [modern browser](https://tailwindcss.com/docs/compatibility#browser-support) to render correctly.
> [!note]
> Use this function with Tailwind CSS v4.0 and later, which require a relatively [modern browser] to render correctly.
[modern browser]: https://tailwindcss.com/docs/compatibility#browser-support
## Setup
@@ -27,11 +29,12 @@ Use the `css.TailwindCSS` function to process your Tailwind CSS files. This func
Install the Tailwind CSS CLI v4.0 or later:
```sh
```sh {copy=true}
npm install --save-dev tailwindcss @tailwindcss/cli
```
The TailwindCSS CLI is also available as a [standalone executable] if you want to use it without installing Node.js.
The Tailwind CSS CLI is also available as a [standalone executable]. You must install it outside of your project directory and ensure its path is included in your system's `PATH` environment variable.
[standalone executable]: https://github.com/tailwindlabs/tailwindcss/releases/latest
@@ -40,21 +43,23 @@ The TailwindCSS CLI is also available as a [standalone executable] if you want t
Add this to your site configuration:
{{< code-toggle file=hugo copy=true >}}
[[module.mounts]]
source = "assets"
target = "assets"
[[module.mounts]]
source = "hugo_stats.json"
target = "assets/notwatching/hugo_stats.json"
disableWatch = true
[build.buildStats]
enable = true
[[build.cachebusters]]
source = "assets/notwatching/hugo_stats\\.json"
target = "css"
[[build.cachebusters]]
source = "(postcss|tailwind)\\.config\\.js"
target = "css"
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = 'assets/notwatching/hugo_stats\.json'
target = 'css'
[[build.cachebusters]]
source = '(postcss|tailwind)\.config\.js'
target = 'css'
[module]
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
disableWatch = true
source = 'hugo_stats.json'
target = 'assets/notwatching/hugo_stats.json'
{{< /code-toggle >}}
### Step 3
@@ -72,20 +77,15 @@ 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:
```go-html-template {file="layouts/partials/css.html" copy=true}
{{ with (templates.Defer (dict "key" "global")) }}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict
"minify" hugo.IsProduction
"inlineImports" true
}}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsProduction }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ else }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
```go-html-template {file="layouts/_partials/css.html" copy=true}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict "minify" (not hugo.IsDevelopment) }}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
{{ end }}
@@ -94,33 +94,16 @@ Create a partial template to process the CSS with the Tailwind CSS CLI:
### Step 5
Call the partial template from your base template:
Call the partial template from your base template, deferring template execution until after all sites and output formats have been rendered:
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html" copy=true}
<head>
...
{{ partialCached "css.html" . }}
{{ with (templates.Defer (dict "key" "global")) }}
{{ partial "css.html" . }}
{{ end }}
...
<head>
```
### Step 6
Optionally create a `tailwind.config.js` file in the root of your project as shown below. This is necessary if you use the [Tailwind CSS IntelliSense
extension] for Visual Studio Code.
[Tailwind CSS IntelliSense
extension]: https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
```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.
https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
The rest of this file is intentionally empty.
*/
</head>
```
## Options
@@ -131,8 +114,9 @@ minify
optimize
: (`bool`) Whether to optimize the output without minifying. Default is `false`.
inlineImports
: (`bool`) Whether to enable inlining of `@import` statements. Inlining is performed recursively, but currently once only per file. It is not possible to import the same file in different scopes (root, media query, etc.). Note that this import routine does not care about the CSS specification, so you can have `@import` statements anywhere in the file. Default is `false`.
disableInlineImports
: {{< new-in 0.147.4 />}}
: (`bool`) Whether to disable inlining of `@import` statements. Inlining is performed recursively, but currently once only per file. It is not possible to import the same file in different scopes (root, media query, etc.). Note that this import routine does not care about the CSS specification, so you can have `@import` statements anywhere in the file. Default is `false`.
skipInlineImportsNotFound
: (`bool`) Whether to allow the build process to continue despite unresolved import statements, preserving the original import declarations. It is important to note that the inline importer does not process URL-based imports or those with media queries, and these will remain unaltered even when this option is disabled. Default is `false`.

View File

@@ -18,7 +18,7 @@ The timer starts when you instantiate it, and stops when you call its `Stop` met
```go-html-template
{{ $t := debug.Timer "TestSqrt" }}
{{ range seq 2000 }}
{{ range 2000 }}
{{ $f := math.Sqrt . }}
{{ end }}
{{ $t.Stop }}

View File

@@ -66,7 +66,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.
```go-html-template {file="layouts/_default/_markup/render-codeblock-goat.html"}
```go-html-template {file="layouts/_markup/render-codeblock-goat.html"}
{{ $caption := or .Attributes.caption "" }}
{{ $class := or .Attributes.class "diagram" }}
{{ $id := or .Attributes.id (printf "diagram-%d" (add 1 .Ordinal)) }}

View File

@@ -30,7 +30,7 @@ When a `Page` object is not in context, you can use the global `page` function:
## Explanation
Hugo almost always passes a `Page` as the data context into the top-level template (e.g., `single.html`). The one exception is the multihost sitemap template. This means that you can access the current page with the `.` in the template.
Hugo almost always passes a `Page` as the data context into the top-level template (e.g., `baseof.html`). The one exception is the multihost sitemap template. This means that you can access the current page with the `.` in the template.
But when you are deeply nested inside of a [content view](g), [partial](g), or [render hook](g), it is not always practical or possible to access the `Page` object.

View File

@@ -23,7 +23,7 @@ and then executing it in place:
```
The typical use is to define a set of root templates that are then customized by redefining the block templates within.
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
<body>
<main>
{{ block "main" . }}
@@ -33,14 +33,14 @@ The typical use is to define a set of root templates that are then customized by
</body>
```
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ end }}
```
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}

View File

@@ -28,7 +28,7 @@ Use with the [`partial`] function:
```go-html-template
{{ partial "inline/foo.html" (dict "answer" 42) }}
{{ define "partials/inline/foo.html" }}
{{ define "_partials/inline/foo.html" }}
{{ printf "The answer is %v." .answer }}
{{ end }}
```
@@ -43,8 +43,21 @@ Use with the [`template`] function:
{{ end }}
```
> [!warning]
> Only [template comments] are allowed outside of the `define` and `end` statements. Avoid placing any other text, including HTML comments, outside of these boundaries. Doing so will cause rendering issues, potentially resulting in a blank page. See the example below.
```go-html-template {file="layouts/do-not-do-this.html"}
<div>This div element broke your template.</div>
{{ define "main" }}
<h2>{{ .Title }}</h2>
{{ .Content }}
{{ end }}
<!-- An HTML comment will break your template too. -->
```
{{% include "/_common/functions/go-template/text-template.md" %}}
[`block`]: /functions/go-template/block/
[`template`]: /functions/go-template/block/
[`partial`]: /functions/partials/include/
{{% include "/_common/functions/go-template/text-template.md" %}}
[template comments]: /templates/introduction/#comments

View File

@@ -11,7 +11,7 @@ params:
aliases: [/functions/range]
---
{{% include "/_common/functions/truthy-falsy.md" %}}
The collection may be a slice, a map, or an integer.
```go-html-template
{{ $s := slice "foo" "bar" "baz" }}
@@ -40,19 +40,22 @@ Within a range block:
At the top of a page template, the [context](g) (the dot) is a `Page` object. Within the `range` block, the context is bound to each successive element.
With this contrived example that uses the [`seq`] function to generate a slice of integers:
With this contrived example:
```go-html-template
{{ range seq 3 }}
{{ .Title }}
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ .Title }}
{{ end }}
```
Hugo will throw an error:
can't evaluate field Title in type int
```text
can't evaluate field Title in type int
```
The error occurs because we are trying to use the `.Title` method on an integer instead of a `Page` object. Within the `range` block, if we want to render the page title, we need to get the context passed into the template.
The error occurs because we are trying to use the `.Title` method on a string instead of a `Page` object. Within the `range` block, if we want to render the page title, we need to get the context passed into the template.
> [!note]
> Use the `$` to get the context passed into the template.
@@ -60,15 +63,18 @@ The error occurs because we are trying to use the `.Title` method on an integer
This template will render the page title three times:
```go-html-template
{{ range seq 3 }}
{{ $.Title }}
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ $.Title }}
{{ end }}
```
> [!note]
> Gaining a thorough understanding of context is critical for anyone writing template code.
## Array or slice of scalars
## Examples
### Slice of scalars
This template code:
@@ -121,7 +127,7 @@ Is rendered to:
<p>2: baz</p>
```
## Array or slice of maps
### Slice of maps
This template code:
@@ -144,7 +150,7 @@ Is rendered to:
<p>Joey is 24</p>
```
## Array or slice of pages
### Slice of pages
This template code:
@@ -162,7 +168,7 @@ Is rendered to:
<h2><a href="/articles/article-1/">Article 1</a></h2>
```
## Maps
### Maps
This template code:
@@ -182,9 +188,32 @@ Is rendered to:
Unlike ranging over an array or slice, Hugo sorts by key when ranging over a map.
### Integers
{{< new-in 0.123.0 />}}
Ranging over a positive integer `n` executes the block `n` times, with the context starting at zero and incrementing by one in each iteration.
```go-html-template
{{ $s := slice }}
{{ range 1 }}
{{ $s = $s | append . }}
{{ end }}
{{ $s }} → [0]
```
```go-html-template
{{ $s := slice }}
{{ range 3 }}
{{ $s = $s | append . }}
{{ end }}
{{ $s }} → [0 1 2]
```
Ranging over a non-positive integer executes the block zero times.
{{% include "/_common/functions/go-template/text-template.md" %}}
[`break`]: /functions/go-template/break/
[`continue`]: /functions/go-template/continue/
[`else`]: /functions/go-template/else/
[`seq`]: /functions/collections/seq/

View File

@@ -23,7 +23,7 @@ A `return` statement without a value returns an empty string of type `template.H
By way of example, let's create a partial template that _renders_ HTML, describing whether the given number is odd or even:
```go-html-template {file="layouts/partials/odd-or-even.html"}
```go-html-template {file="layouts/_partials/odd-or-even.html"}
{{ if math.ModBool . 2 }}
<p>{{ . }} is even</p>
{{ else }}
@@ -39,7 +39,7 @@ When called, the partial renders HTML:
Instead of rendering HTML, let's create a partial that _returns_ a boolean value, reporting whether the given number is even:
```go-html-template {file="layouts/partials/is-even.html"}
```go-html-template {file="layouts/_partials/is-even.html"}
{{ return math.ModBool . 2 }}
```
@@ -60,8 +60,6 @@ Hugo renders:
<p>42 is even</p>
```
See additional examples in the [partial templates] section.
## Usage
> [!note]
@@ -71,7 +69,7 @@ A partial that returns a value must contain only one `return` statement, placed
For example:
```go-html-template {file="layouts/partials/is-even.html"}
```go-html-template {file="layouts/_partials/is-even.html"}
{{ $result := false }}
{{ if math.ModBool . 2 }}
{{ $result = "even" }}
@@ -84,7 +82,7 @@ For example:
> [!note]
> The construct below is incorrect; it contains more than one `return` statement.
```go-html-template {file="layouts/partials/do-not-do-this.html"}
```go-html-template {file="layouts/_partials/do-not-do-this.html"}
{{ if math.ModBool . 2 }}
{{ return "even" }}
{{ else }}
@@ -92,5 +90,4 @@ For example:
{{ end }}
```
[partial templates]: /templates/partial/#returning-a-value-from-a-partial
[text/template package]: https://pkg.go.dev/text/template

View File

@@ -10,27 +10,7 @@ params:
signatures: ['template NAME [CONTEXT]']
---
Use the `template` function to execute any of these [embedded templates](g):
- [`disqus.html`]
- [`google_analytics.html`]
- [`opengraph.html`]
- [`pagination.html`]
- [`schema.html`]
- [`twitter_cards.html`]
For example:
```go-html-template
{{ range (.Paginate .Pages).Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ template "_internal/pagination.html" . }}
```
You can also use the `template` function to execute a defined template:
Use the `template` function to execute a defined template:
```go-html-template
{{ template "foo" (dict "answer" 42) }}
@@ -40,12 +20,12 @@ You can also use the `template` function to execute a defined template:
{{ end }}
```
The example above can be rewritten using an [inline partial] template:
The example above can be rewritten using an inline partial template:
```go-html-template
{{ partial "inline/foo.html" (dict "answer" 42) }}
{{ define "partials/inline/foo.html" }}
{{ define "_partials/inline/foo.html" }}
{{ printf "The answer is %v." .answer }}
{{ end }}
```
@@ -58,13 +38,5 @@ The key distinctions between the preceding two examples are:
{{% include "/_common/functions/go-template/text-template.md" %}}
[`disqus.html`]: /templates/embedded/#disqus
[`google_analytics.html`]: /templates/embedded/#google-analytics
[`opengraph.html`]: /templates/embedded/#open-graph
[`pagination.html`]: /templates/embedded/#pagination
[`partialCached`]: /functions/partials/includecached/
[`partial`]: /functions/partials/include/
[`return`]: /functions/go-template/return/
[`schema.html`]: /templates/embedded/#schema
[`twitter_cards.html`]: /templates/embedded/#x-twitter-cards
[inline partial]: /templates/partial/#inline-partials

View File

@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.144.2">
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.147.9">
```

View File

@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Version }} → 0.144.2
{{ hugo.Version }} → 0.147.9
```

View File

@@ -68,7 +68,7 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul
To include a QR code that points to the `Permalink` of the current page:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with images.QR .Permalink }}
<img
src="{{ .RelPermalink }}"

View File

@@ -18,6 +18,10 @@ alignx
: {{< new-in 0.141.0 />}}
: (`string`) The horizontal alignment of the text relative to the horizontal offset, one of `left`, `center`, or `right`. Default is `left`.
aligny
: {{< new-in 0.147.0 />}}
: (`string`) The vertical alignment of the text relative to the vertical offset, one of `top`, `center`, or `bottom`. Default is `top`.
color
: (`string`) The font color, either a 3-digit or 6-digit hexadecimal color code. Default is `#ffffff` (white).
@@ -71,6 +75,7 @@ Create the filter, centering the text horizontally and vertically:
{{ with $r = resources.Get $imagePath }}
{{ $opts := dict
"alignx" "center"
"aligny" "center"
"color" "#fbfaf5"
"font" $font
"linespacing" 8

View File

@@ -20,18 +20,18 @@ The `js.Build` function uses the [evanw/esbuild] package to:
```go-html-template
{{ with resources.Get "js/main.js" }}
{{ $opts := dict
"minify" hugo.IsProduction
"sourceMap" (cond hugo.IsProduction "" "external")
{{$opts := dict
"minify" (not hugo.IsDevelopment)
"sourceMap" (cond hugo.IsDevelopment "external" "")
"targetPath" "js/main.js"
}}
{{ with . | js.Build $opts }}
{{ if hugo.IsProduction }}
{{ if hugo.IsDevelopment }}
<script src="{{ .RelPermalink }}"></script>
{{ else }}
{{ with . | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ else }}
<script src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
{{ end }}

View File

@@ -24,6 +24,6 @@ A more practical example is to fill in the missing translations from the other l
```sh
{{ $pages := .Site.RegularPages }}
{{ range .Site.Home.Translations }}
{{ $pages = $pages | lang.Merge .Site.RegularPages }}
{{ $pages = $pages | lang.Merge .Site.RegularPages }}
{{ end }}
```

View File

@@ -12,14 +12,14 @@ params:
The counter is global for both monolingual and multilingual sites, and its initial value for each build is&nbsp;1.
```go-html-template
{{ warnf "single.html called %d times" math.Counter }}
```go-html-template {file="layouts/page.html"}
{{ warnf "page.html called %d times" math.Counter }}
```
```sh
WARN single.html called 1 times
WARN single.html called 2 times
WARN single.html called 3 times
```text
WARN page.html called 1 times
WARN page.html called 2 times
WARN page.html called 3 times
```
Use this function to:

View File

@@ -0,0 +1,27 @@
---
title: math.MaxInt64
description: Returns the maximum value for a signed 64-bit integer.
categories: []
keywords: []
params:
functions_and_methods:
aliases: []
returnType: int64
signatures: [math.MaxInt64]
---
{{< new-in 0.147.3 />}}
```go-html-template
{{ math.MaxInt64 }} → 9223372036854775807
```
This function is helpful for simulating a loop that continues indefinitely until a break condition is met. For example:
```go-html-template
{{ range math.MaxInt64 }}
{{ if eq . 42 }}
{{ break }}
{{ end }}
{{ end }}
```

View File

@@ -39,7 +39,7 @@ To inspect the data structure:
To list the GET and POST operations for each of the API paths:
```go-html-template
{{ range $path, $details := $api.Paths }}
{{ range $path, $details := $api.Paths.Map }}
<p>{{ $path }}</p>
<dl>
{{ with $details.Get }}
@@ -54,6 +54,11 @@ To list the GET and POST operations for each of the API paths:
{{ end }}
```
> [!warning]
> The unmarshaled data structure is created with [`kin-openapi`](https://github.com/getkin/kin-openapi). Many fields are structs or pointers (not maps), and therefore require accessors or other methods for indexing and iteration.
> For example, prior to [`kin-openapi` v0.122.0](https://github.com/getkin/kin-openapi#v01220) / [Hugo v0.121.0](https://github.com/gohugoio/hugo/releases/tag/v0.121.0), `Paths` was a map (so `.Paths` was iterable) and it is now a pointer (and requires the `.Paths.Map` accessor, as in the example above).
> See the [`kin-openapi` godoc for OpenAPI 3](https://pkg.go.dev/github.com/getkin/kin-openapi/openapi3) for full type definitions.
Hugo renders this to:
```html

View File

@@ -19,7 +19,7 @@ In this example we have three partial templates:
```text
layouts/
└── partials/
└── _partials/
├── average.html
├── breadcrumbs.html
└── footer.html

View File

@@ -16,7 +16,7 @@ Without a [`return`] statement, the `partialCached` function returns a string of
The `partialCached` function can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation.
> [!note]
> Each Site (or language) has its own `partialCached` cache, so each site will execute a partial once.
> Each site (or language) has its own `partialCached` cache, so each site will execute a partial once.
>
> Hugo renders pages in parallel, and will render the partial more than once with concurrent calls to the `partialCached` function. After Hugo caches the rendered partial, new pages entering the build pipeline will use the cached result.
@@ -28,7 +28,7 @@ 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:
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
{{ partialCached "footer.html" . .Section }}
```

View File

@@ -22,9 +22,9 @@ Let's say you need to publish a file named "site.json" in the root of your `publ
```json
{
"build_date": "2025-01-16T19:14:41-08:00",
"hugo_version": "0.141.0",
"last_modified": "2025-01-16T19:14:46-08:00"
"build_date": "2025-05-03T19:14:41-08:00",
"hugo_version": "0.147.9",
"last_modified": "2025-05-03T19:14:46-08:00"
}
```

View File

@@ -47,7 +47,7 @@ debug = true
To visually mark where a template begins and ends execution:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ define "main" }}
{{ if site.Params.debug }}
<div class="debug">[entering {{ templates.Current.Filename }}]</div>
@@ -66,7 +66,7 @@ To visually mark where a template begins and ends execution:
To display the chain of templates that led to the current one, create a partial template that iterates through its ancestors:
```go-html-template {file="layouts/partials/template-call-stack.html" copy=true}
```go-html-template {file="layouts/_partials/template-call-stack.html" copy=true}
{{ with templates.Current }}
<div class="debug">
{{ range .Ancestors }}
@@ -81,7 +81,7 @@ To display the chain of templates that led to the current one, create a partial
Then call the partial from any template:
```go-html-template {file="layouts/partials/footer/copyright.html" copy=true}
```go-html-template {file="layouts/_partials/footer/copyright.html" copy=true}
{{ if site.Params.debug }}
{{ partial "template-call-stack.html" . }}
{{ end }}
@@ -90,15 +90,15 @@ Then call the partial from any template:
The rendered template stack would look something like this:
```text
/home/user/project/layouts/partials/footer/copyright.html
/home/user/project/themes/foo/layouts/partials/footer.html
/home/user/project/layouts/_default/single.html
/home/user/project/themes/foo/layouts/_default/baseof.html
/home/user/project/layouts/_partials/footer/copyright.html
/home/user/project/themes/foo/layouts/_partials/footer.html
/home/user/project/layouts/page.html
/home/user/project/themes/foo/layouts/baseof.html
```
To reverse the order of the entries, chain the `Reverse` method to the `Ancestors` method:
```go-html-template {file="layouts/partials/template-call-stack.html" copy=true}
```go-html-template {file="layouts/_partials/template-call-stack.html" copy=true}
{{ with templates.Current }}
<div class="debug">
{{ range .Ancestors.Reverse }}
@@ -115,7 +115,7 @@ To reverse the order of the entries, chain the `Reverse` method to the `Ancestor
To render links that, when clicked, will open the template in Microsoft Visual Studio Code, create a partial template with anchor elements that use the `vscode` URI scheme:
```go-html-template {file="layouts/partials/template-open-in-vs-code.html" copy=true}
```go-html-template {file="layouts/_partials/template-open-in-vs-code.html" copy=true}
{{ with templates.Current.Parent }}
<div class="debug">
<a href="vscode://file/{{ .Filename }}">{{ .Name }}</a>
@@ -128,7 +128,7 @@ To render links that, when clicked, will open the template in Microsoft Visual S
Then call the partial from any template:
```go-html-template {file="layouts/_default/single.html" copy=true}
```go-html-template {file="layouts/page.html" copy=true}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
@@ -141,7 +141,7 @@ Then call the partial from any template:
Use the same approach to render the entire call stack as links:
```go-html-template {file="layouts/partials/template-call-stack.html" copy=true}
```go-html-template {file="layouts/_partials/template-call-stack.html" copy=true}
{{ with templates.Current }}
<div class="debug">
{{ range .Ancestors }}

View File

@@ -14,33 +14,34 @@ aliases: [/functions/templates.defer]
{{< new-in 0.128.0 />}}
> [!note]
> This feature is meant to be used in the main page layout files/templates, and has undefined behavior when used from shortcodes, partials or render hook templates. See [this issue](https://github.com/gohugoio/hugo/issues/13492#issuecomment-2734700391) for more info.
> This feature should only be used in the main page template, typically `layouts/baseof.html`. Using it in shortcodes, partials, or render hook templates may lead to unpredictable results. For further details, please refer to [this issue].
[this issue]: https://github.com/gohugoio/hugo/issues/13492#issuecomment-2734700391
In some rare use cases, you may need to defer the execution of a template until after all sites and output formats have been rendered. One such example could be [TailwindCSS](/functions/css/tailwindcss/) using the output of [hugo_stats.json](/configuration/build/) to determine which classes and other HTML identifiers are being used in the final output:
```go-html-template
{{ with (templates.Defer (dict "key" "global")) }}
{{ $t := debug.Timer "tailwindcss" }}
{{ with resources.Get "css/styles.css" }}
{{ $opts := dict
"inlineImports" true
"optimize" hugo.IsProduction
}}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}" />
{{ else }}
{{ with . | minify | fingerprint }}
<link
rel="stylesheet"
href="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous" />
{{ end }}
```go-html-template {file="layouts/baseof.html" copy=true}
<head>
...
{{ with (templates.Defer (dict "key" "global")) }}
{{ partial "css.html" . }}
{{ end }}
...
</head>
```
```go-html-template {file="layouts/_partials/css.html" copy=true}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict "minify" (not hugo.IsDevelopment) }}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
{{ end }}
{{ $t.Stop }}
{{ end }}
```
@@ -52,19 +53,23 @@ In some rare use cases, you may need to defer the execution of a template until
For the above to work well when running the server (or `hugo -w`), you want to have a configuration similar to this:
{{< code-toggle file=hugo >}}
[build]
[build.buildStats]
enable = true
[[build.cachebusters]]
source = 'assets/notwatching/hugo_stats\.json'
target = 'css'
[[build.cachebusters]]
source = '(postcss|tailwind)\.config\.js'
target = 'css'
[module]
[[module.mounts]]
source = "hugo_stats.json"
target = "assets/notwatching/hugo_stats.json"
disableWatch = true
[build.buildStats]
enable = true
[[build.cachebusters]]
source = "assets/notwatching/hugo_stats\\.json"
target = "styles\\.css"
[[build.cachebusters]]
source = "(postcss|tailwind)\\.config\\.js"
target = "css"
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
disableWatch = true
source = 'hugo_stats.json'
target = 'assets/notwatching/hugo_stats.json'
{{< /code-toggle >}}
## Options

View File

@@ -17,7 +17,7 @@ Use the `templates.Exists` function with dynamic template paths:
```go-html-template
{{ $partialPath := printf "headers/%s.html" .Type }}
{{ if templates.Exists ( printf "partials/%s" $partialPath ) }}
{{ if templates.Exists ( printf "_partials/%s" $partialPath ) }}
{{ partial $partialPath . }}
{{ else }}
{{ partial "headers/default.html" . }}

View File

@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
aliases: []
returnType: types.Result[template.HTML]
returnType: template.HTML
signatures: ['transform.ToMath INPUT [OPTIONS]']
aliases: [/functions/tomath]
---
@@ -58,12 +58,25 @@ minRuleThickness
: (`float`) The minimum thickness of the fraction lines in `em`. Default is `0.04`.
output
: (`string`). Determines the markup language of the output, one of `html`, `mathml`, or `htmlAndMathml`. Default is `mathml`.
: (`string`) Determines the markup language of the output, one of `html`, `mathml`, or `htmlAndMathml`. Default is `mathml`.
With `html` and `htmlAndMathml` you must include the KaTeX style sheet within the `head` element of your base template.
```html
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css" rel="stylesheet">
strict
: {{< new-in 0.147.6 />}}
: (`string`) Controls how KaTeX handles LaTeX features that offer convenience but aren't officially supported, one of `error`, `ignore`, or `warn`. Default is `error`.
- `error`: Throws an error when convenient, unsupported LaTeX features are encountered.
- `ignore`: Allows convenient, unsupported LaTeX features without any feedback.
- `warn`: {{< new-in 0.147.7 />}} Emits a warning when convenient, unsupported LaTeX features are encountered.
: The `newLineInDisplayMode` error code, which flags the use of `\\`
or `\newline` in display mode outside an array or tabular environment, is
intentionally designed not to throw an error, despite this behavior
being questionable.
throwOnError
: (`bool`) Whether to throw a `ParseError` when KaTeX encounters an unsupported command or invalid LaTeX. Default is `true`.
@@ -96,13 +109,13 @@ inline = [['\(', '\)']]
{{< /code-toggle >}}
> [!note]
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration, you will need to double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration, you must double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
### Step 2
Create a [passthrough render hook] to capture and render the LaTeX markup.
```go-html-template {file="layouts/_default/_markup/render-passthrough.html" copy=true}
```go-html-template {file="layouts/_markup/render-passthrough.html" copy=true}
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
{{- with .Err }}
@@ -118,11 +131,11 @@ Create a [passthrough render hook] to capture and render the LaTeX markup.
In your base template, conditionally include the KaTeX CSS within the head element.
```go-html-template {file="layouts/_default/baseof.html" copy=true}
```go-html-template {file="layouts/baseof.html" copy=true}
<head>
{{ $noop := .WordCount }}
{{ if .Page.Store.Get "hasMath" }}
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css" rel="stylesheet">
{{ end }}
</head>
```

View File

@@ -180,7 +180,7 @@ To render an HTML table from a CSV file:
To extract a subset of the data, or to sort the data, unmarshal to a map instead of a slice:
```go-html-template
{{ $data := slice }}
{{ $data := dict }}
{{ $file := "pets.csv" }}
{{ with or (.Resources.Get $file) (resources.Get $file) }}
{{ $opts := dict "targetType" "map" }}

View File

@@ -31,7 +31,7 @@ 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:
```xml {file="layouts/_default/rss.xml"}
```xml {file="layouts/rss.xml"}
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
```

View File

@@ -62,7 +62,7 @@ This course covers the basics of using the Hugo static site generator. Work your
1. [Content Organization](https://www.giraffeacademy.com/static-site-generators/hugo/content-organization/)
1. [Front Matter](https://www.giraffeacademy.com/static-site-generators/hugo/front-matter/)
1. [Archetypes](https://www.giraffeacademy.com/static-site-generators/hugo/archetypes/)
1. [Shortcodes](https://www.giraffeacademy.com/static-site-generators/hugo/archetypes/)
1. [Shortcodes](https://www.giraffeacademy.com/static-site-generators/hugo/shortcodes/)
1. [Taxonomies](https://www.giraffeacademy.com/static-site-generators/hugo/taxonomies/)
1. [Template Basics](https://www.giraffeacademy.com/static-site-generators/hugo/introduction-to-templates/)
1. [List Page Templates](https://www.giraffeacademy.com/static-site-generators/hugo/list-page-templates/)

View File

@@ -44,9 +44,9 @@ version: 1
env:
variables:
# Application versions
DART_SASS_VERSION: 1.85.0
GO_VERSION: 1.23.3
HUGO_VERSION: 0.144.2
DART_SASS_VERSION: 1.89.2
GO_VERSION: 1.24.2
HUGO_VERSION: 0.147.9
# Time zone
TZ: America/Los_Angeles
# Cache

View File

@@ -51,9 +51,11 @@ git remote add origin https://codeberg.org/<YourUsername>/pages.git
git push -u origin main
```
## Automated deployment
## Automated deployment using Woodpecker CI
In order to automatically deploy your Hugo website, you need to have or [request] access to Codeberg's CI, as well as add a `.woodpecker.yaml` file in the root of your project. A template and additional instructions are available in the official [examples repository].
There are two methods you can use to deploy your Hugo website to Codeberg automatically. These are: Woodpecker CI and Forgejo Actions.
To use Codeberg's Woodpecker CI, you need to have or [request] access to it, as well as add a `.woodpecker.yaml` file in the root of your project. A template and additional instructions are available in the official [examples repository].
[request]: https://codeberg.org/Codeberg-e.V./requests/issues/new?template=ISSUE_TEMPLATE%2fWoodpecker-CI.yaml
[examples repository]: https://codeberg.org/Codeberg-CI/examples/src/branch/main/Hugo/.woodpecker.yaml
@@ -74,7 +76,178 @@ git remote add origin https://codeberg.org/<YourUsername>/<YourWebsite>.git
git push -u origin main
```
Your project will then be built and deployed by Codeberg's CI.
Your project will then be built and deployed by Codeberg's Woodpecker CI.
## Automated deployment using Forgejo Actions
The other way to deploy your website to Codeberg pages automatically is to make use of Forgejo Actions. Actions need a _runner_ to work, and Codeberg has [great documentation] on how to set one up yourself. However, Codeberg provides a [handful of humble runners] themselves (they say this feature is in "open alpha"), which actually seem powerful enough to build at least relatively simple websites.
[great documentation]: https://docs.codeberg.org/ci/actions/
[handful of humble runners]: https://codeberg.org/actions/meta
To deploy your website this way, you don't need to request any access. All you need to do is enable actions in your repository settings (see the documentation link above) and add a workflow configuration file, for example, `hugo.yaml`, to the `.forgejo/workflows/` directory in your website's source repository.
Two examples of such a file are provided below.
The first file should work for automatically building your website from the source branch (`main` in this case) and committing the result to the target branch (`pages`). Without changes, this file should make your built website accessible under `https://<YourUsername>.codeberg.page/<YourWebsiteRepositoryName>/`:
```yaml {file=".forgejo/workflows/hugo.yaml" copy=true}
name: Deploy Hugo site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches:
# If you want to build from a different branch, change it here.
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
# You can find the list of available runners on https://codeberg.org/actions/meta, or run one yourself.
runs-on: codeberg-tiny-lazy
container:
# Specify "hugomods/hugo:exts" if you want to always use the latest version of Hugo for building.
image: "hugomods/hugo:exts-0.147.9"
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Generate static files with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify
- name: Upload generated files
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: Generated files
path: public/
deploy:
needs: [ build ]
runs-on: codeberg-tiny-lazy
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Checkout the target branch and clean it up
# If you want to commit to a branch other than "pages", change the two references below, as well as the reference in the last step.
run: |
git checkout pages || git switch --orphan pages && \
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
- name: Download generated files
uses: https://code.forgejo.org/actions/download-artifact@v3
with:
name: Generated files
- name: Publish the website
run: |
git config user.email codeberg-ci && \
git config user.name "Codeberg CI" && \
git add . && \
git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}" && \
git push origin pages
```
The second file implements a more complex scenario: having your website sources in one repository and the resulting static website in another repository (in this case, `pages`). If you want Codeberg to make your website available at the root of your pages subdomain (`https://<YourUsername>.codeberg.page/`), you have to push that website to the default branch of your repository named `pages`.
Since this action involves more than one repository, it will require a bit more preparation:
1. Create the target repository. Name it `pages`.
2. Generate a new SSH key. *Do not* use any of your own SSH keys for this, but generate one for this specific task only. On Linux, BSD, and, likely, other operating systems, you can open a terminal emulator and run the following command to generate the key:
```shell
ssh-keygen -f pagesbuild -P ""
```
This will generate two files in your current directory: `pagesbuild` (private key) and `pagesbuild.pub` (public key).
3. Add the newly generated public key as a deploy key to your `pages` repository: navigate to its Settings, click on "Deploy keys" in the left menu, click the "Add deploy key" button, give it a name (e.g. "Actions deploy key"), paste the contents of the **public** key file (`pagesbuild.pub`) to the Content field, tick the "Enable write access" checkbox, then submit the form.
4. Navigate back to your source repository settings, expand the "Actions" menu and click on "Secrets". Then click "Add Secret", enter "DEPLOY_KEY" as the secret name and paste the contents of the newly generated **private** key file (`pagesbuild`) into the Value field.
5. Navigate to the "Variables" submenu of the "Actions" menu and add the following variables:
| Name | Value |
|---------------------|----------------------------------------------------------------------------------|
| `TARGET_REPOSITORY` | `<YourUsername>/pages` |
| `TARGET_BRANCH` | `main` (enter the default branch name of the `pages` repo here) |
| `SSH_KNOWN_HOSTS` | (paste the output you get by running `ssh-keyscan codeberg.org` in the terminal) |
Once you've done all of the above, commit the following file to your repository as `.forgejo/workflows/hugo.yaml`. As you can see, the `deploy` job of this workflow is slightly different from the file above:
```yaml {file=".forgejo/workflows/hugo.yaml" copy=true}
name: Deploy Hugo site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches:
# If you want to build from a different branch, change it here.
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: codeberg-tiny-lazy
container:
# Specify "hugomods/hugo:exts" if you want to always use the latest version of Hugo for building.
image: "hugomods/hugo:exts-0.147.9"
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Generate static files with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--source ${PWD} \
--destination ${PWD}/public/
- name: Upload generated files
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: Generated files
path: public/
deploy:
needs: [ build ]
runs-on: codeberg-tiny-lazy
steps:
- name: Clone the repository
uses: https://code.forgejo.org/actions/checkout@v4
with:
repository: ${{ vars.TARGET_REPOSITORY }}
ref: ${{ vars.TARGET_BRANCH }}
submodules: recursive
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}
- name: Remove all files
run: |
rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$')
- name: Download generated files
uses: https://code.forgejo.org/actions/download-artifact@v3
with:
name: Generated files
- name: Commit and push the website
run: |
git config user.email codeberg-ci && \
git config user.name "Codeberg CI" && \
git add -v . && \
git commit -v --allow-empty --message "Codeberg build for ${GITHUB_SHA}" && \
git push -v origin ${{ vars.TARGET_BRANCH }}
```
Once you commit one of the two files to your website source repository, you should see your first automated build firing up pretty soon. You can also trigger it manually by navigating to the **Actions** section of your repository web page, choosing **hugo.yaml** on the left and clicking on **Run workflow**.
## Other resources

View File

@@ -107,7 +107,8 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.145.0
DART_SASS_VERSION: 1.89.2
HUGO_VERSION: 0.147.9
HUGO_ENVIRONMENT: production
TZ: America/Los_Angeles
steps:
@@ -116,7 +117,11 @@ jobs:
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
run: |
wget -O ${{ runner.temp }}/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz \
&& tar -xf ${{ runner.temp }}/dart-sass.tar.gz --directory ${{ runner.temp }} \
&& mv ${{ runner.temp }}/dart-sass/ /usr/local/bin \
&& echo "/usr/local/bin/dart-sass" >> $GITHUB_PATH
- name: Checkout
uses: actions/checkout@v4
with:

View File

@@ -23,17 +23,18 @@ Define your [CI/CD](g) jobs by creating a `.gitlab-ci.yml` file in the root of y
```yaml {file=".gitlab-ci.yml" copy=true}
variables:
DART_SASS_VERSION: 1.87.0
DART_SASS_VERSION: 1.89.2
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
HUGO_VERSION: 0.146.7
HUGO_VERSION: 0.147.9
NODE_VERSION: 22.x
TZ: America/Los_Angeles
image:
name: golang:1.24.2-bookworm
pages:
stage: deploy
script:
# Install brotli
- apt-get update

View File

@@ -113,8 +113,8 @@ Create a new file named netlify.toml in the root of your project directory. In i
```toml {file="netlify.toml"}
[build.environment]
GO_VERSION = "1.24"
HUGO_VERSION = "0.146.7"
GO_VERSION = "1.24.2"
HUGO_VERSION = "0.147.9"
NODE_VERSION = "22"
TZ = "America/Los_Angeles"
@@ -127,9 +127,9 @@ If your site requires Dart Sass to transpile Sass to CSS, the configuration file
```toml {file="netlify.toml"}
[build.environment]
DART_SASS_VERSION = "1.87.0"
GO_VERSION = "1.24"
HUGO_VERSION = "0.146.7"
DART_SASS_VERSION = "1.89.2"
GO_VERSION = "1.24.2"
HUGO_VERSION = "0.147.9"
NODE_VERSION = "22"
TZ = "America/Los_Angeles"

View File

@@ -1,6 +1,6 @@
---
title: Host on Render
description: Host your on Render.
description: Host your site on Render.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-render/]

View File

@@ -62,7 +62,7 @@ weight = 20
With this template code:
```go-html-template {file="layouts/partials/menu.html"}
```go-html-template {file="layouts/_partials/menu.html"}
<ul>
{{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
@@ -83,7 +83,7 @@ In the above note that the `href` attribute of the second `anchor` element is bl
With this template code:
```go-html-template {file="layouts/partials/menu.html"}
```go-html-template {file="layouts/_partials/menu.html"}
<ul>
{{ range .Site.Menus.main }}
<li><a href="{{ or .URL .PageRef }}">{{ .Name }}</a></li>

View File

@@ -14,7 +14,7 @@ The `Data` method on a `Page` object returns a unique data object for each [page
> [!note]
> The `Data` method is only useful within [taxonomy](g) and [term](g) templates.
>
> Themes that are not actively maintained may still use `.Data.Pages` in list templates. Although that syntax remains functional, use one of these methods instead: [`Pages`], [`RegularPages`], or [`RegularPagesRecursive`]
> Themes that are not actively maintained may still use `.Data.Pages` in their templates. Although that syntax remains functional, use one of these methods instead: [`Pages`], [`RegularPages`], or [`RegularPagesRecursive`]
The examples that follow are based on this site configuration:

View File

@@ -16,7 +16,7 @@ title = 'How to make spicy tuna hand rolls'
description = 'Instructions for making spicy tuna hand rolls.'
{{< /code-toggle >}}
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
<head>
...
<meta name="description" content="{{ .Description }}">

View File

@@ -9,9 +9,9 @@ params:
signatures: [PAGE1.Eq PAGE2]
---
In this contrived example from a single template, we list all pages in the current section except for the current page.
In this contrived example we list all pages in the current section except for the current page.
```go-html-template
```go-html-template {file="layouts/page.html"}
{{ $currentPage := . }}
{{ range .CurrentSection.Pages }}
{{ if not (.Eq $currentPage) }}

View File

@@ -102,8 +102,8 @@ Hugo renders this to:
> When using the `Fragments` methods within a shortcode, call the shortcode using [standard notation]. If you use [Markdown notation] the rendered shortcode is included in the creation of the fragments map, resulting in a circular loop.
[`TableOfContents`]: /methods/page/tableofcontents/
[ATX]: https://spec.commonmark.org/0.30/#atx-headings
[ATX]: https://spec.commonmark.org/current/#atx-headings
[Markdown notation]: /content-management/shortcodes/#notation
[setext]: https://spec.commonmark.org/0.30/#setext-headings
[setext]: https://spec.commonmark.org/current/#setext-headings
[standard notation]: /content-management/shortcodes/#notation
[table of contents]: /methods/page/tableofcontents/

View File

@@ -35,9 +35,9 @@ content/
└── _index.md
```
The examples below depict the result of rendering works/paintings/the-mona-lisa.md:
The examples below depict the result of rendering `works/paintings/the-mona-lisa.md`:
```go-html-template {file="layouts/works/single.html"}
```go-html-template {file="layouts/works/page.html"}
{{ with .GetPage "starry-night" }}
{{ .Title }} → Starry Night
{{ end }}

View File

@@ -29,7 +29,7 @@ By example, let's use [Plotly] to render a chart:
The shortcode is simple:
```go-html-template {file="layouts/shortcodes/plotly.html"}
```go-html-template {file="layouts/_shortcodes/plotly.html"}
{{ $id := printf "plotly-%02d" .Ordinal }}
<div id="{{ $id }}"></div>
<script>
@@ -39,7 +39,7 @@ The shortcode is simple:
Now we can selectively load the required JavaScript on pages that call the "plotly" shortcode:
```go-html-template {file="layouts/_default/baseof.html"}
```go-html-template {file="layouts/baseof.html"}
<head>
...
{{ if .HasShortcode "plotly" }}

View File

@@ -22,12 +22,13 @@ Hugo will render the page using contact.html.
```text
layouts/
── _default/
├── baseof.html
├── contact.html
├── home.html
├── list.html
└── single.html
── baseof.html
├── contact.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
└── term.html
```
Although rarely used within a template, you can access the value with:

View File

@@ -11,19 +11,19 @@ params:
This is a convenience method, useful within partial templates that are called from both [shortcodes](g) and page templates.
```go-html-template {file="layouts/shortcodes/foo.html"}
```go-html-template {file="layouts/_shortcodes/foo.html"}
{{ partial "my-partial.html" . }}
```
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`.
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ partial "my-partial.html" . }}
```
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.
```go-html-template {file="layouts/partials/my-partial.html"}
```go-html-template {file="layouts/_partials/my-partial.html"}
The page title is: {{ .Page.Title }}
```

View File

@@ -20,13 +20,13 @@ By default, the number of elements on each pager is determined by your [site con
You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates].
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ $pages := where .Site.RegularPages "Section" "articles" }}
{{ $pages = $pages.ByTitle }}
{{ range (.Paginate $pages 7).Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
{{ template "_internal/pagination.html" . }}
{{ partial "pagination.html" . }}
```
In the example above, we:

View File

@@ -15,11 +15,11 @@ The number of elements on each pager is determined by your [site configuration].
You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. Each of these receives a collection of regular pages in [context](g). When you invoke the `Paginator` method, it paginates the page collection received in context.
```go-html-template {file="layouts/_default/list.html"}
```go-html-template {file="layouts/section.html"}
{{ range .Paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ template "_internal/pagination.html" . }}
{{ partial "pagination.html" . }}
```
In the example above, the embedded pagination template creates navigation links between pagers.

View File

@@ -26,22 +26,21 @@ Although similar to the [`partial`] function, there are key differences.
`Render` method|`partial` function|
:--|:--
The `Page` object is automatically passed to the given template. You cannot pass additional context.| You must specify the context, allowing you to pass a combination of objects, slices, maps, and scalars.
The path to the template is determined by the [content type](g).|You must specify the path to the template, relative to the `layouts/partials` directory.
The path to the template is determined by the [content type](g).|You must specify the path to the template, relative to the `layouts/_partials` directory.
Consider this layout structure:
```text
layouts/
├── _default/
── baseof.html
│ ├── home.html
│ ├── li.html <-- used for other content types
├── list.html
│ ├── single.html
│ └── summary.html
── books/
├── li.html <-- used when content type is "books"
└── summary.html
├── books/
── li.html <-- used when content type is "books"
├── baseof.html
├── home.html
├── li.html <-- used for other content types
├── page.html
├── section.html
── taxonomy.html
└── term.html
```
And this template:
@@ -63,10 +62,10 @@ layouts/books/li.html
For all other content types the `Render` methods calls:
```text
layouts/_default/li.html
layouts/li.html
```
See [content views] for more examples.
[content views]: /templates/content-view/
[content views]: /templates/types/#content-view
[`partial`]: /functions/partials/include/

View File

@@ -9,13 +9,11 @@ params:
signatures: [PAGE.RenderShortcodes]
---
{{< new-in 0.117.0 />}}
Use this method in shortcode templates to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents.
For example:
```go-html-template {file="layouts/shortcodes/include.html" copy=true}
```go-html-template {file="layouts/_shortcodes/include.html" copy=true}
{{ with .Get 0 }}
{{ with $.Page.GetPage . }}
{{- .RenderShortcodes }}

View File

@@ -46,4 +46,4 @@ Render with [Pandoc]:
```
[markup identifier]: /content-management/formats/#classification
[pandoc]: https://www.pandoc.org/
[pandoc]: https://pandoc.org/

View File

@@ -58,7 +58,7 @@ changeFreq = 'hourly'
And this simplistic sitemap template:
```xml {file="layouts/_default/sitemap.xml"}
```xml {file="layouts/sitemap.xml"}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">

View File

@@ -12,8 +12,8 @@ aliases: [/content-management/toc/]
The `TableOfContents` method on a `Page` object returns an ordered or unordered list of the Markdown [ATX] and [setext] headings within the page content.
[atx]: https://spec.commonmark.org/0.30/#atx-headings
[setext]: https://spec.commonmark.org/0.30/#setext-headings
[atx]: https://spec.commonmark.org/current/#atx-headings
[setext]: https://spec.commonmark.org/current/#setext-headings
This template code:

View File

@@ -19,7 +19,16 @@ title = 'About us'
{{ .Title }} → About us
```
With section, taxonomy, and term pages not backed by a file, the `Title` method returns the section name, capitalized and pluralized. You can disable these transformations by setting [`capitalizeListTitles`] and [`pluralizeListTitles`] in your site configuration. For example:
When a page is not backed by a file, the value returned by the `Title` method depends on the page [kind](g).
Page kind|Page title when the page is not backed by a file
:--|:--
home|site title
section|section name (capitalized and pluralized)
taxonomy|taxonomy name (capitalized and pluralized)
term|term name (capitalized and pluralized)
You can disable automatic capitalization and pluralization in your site configuration:
{{< code-toggle file=hugo >}}
capitalizeListTitles = false
@@ -32,8 +41,6 @@ You can change the capitalization style in your site configuration to one of `ap
titleCaseStyle = "firstupper"
{{< /code-toggle >}}
See&nbsp;[details].
See&nbsp;[details].
[`capitalizeListTitles`]: /configuration/all/#capitalizelisttitles
[`pluralizeListTitles`]: /configuration/all/#pluralizelisttitles
[details]: /configuration/all/#title-case-style

View File

@@ -24,5 +24,5 @@ Use the `PageGroups` method with any of the [grouping methods].
{{ end }}
{{ end }}
{{ template "_internal/pagination.html" . }}
{{ partial "pagination.html" . }}
```

View File

@@ -17,5 +17,5 @@ params:
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ template "_internal/pagination.html" . }}
{{ partial "pagination.html" . }}
```

View File

@@ -15,7 +15,7 @@ Based on front matter, Hugo uses several factors to identify content related to
The argument passed to the `Related` method may be a `Page` or an options map. For example, to pass the current page:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ with .Site.RegularPages.Related . | first 5 }}
<p>Related pages:</p>
<ul>
@@ -28,7 +28,7 @@ The argument passed to the `Related` method may be a `Page` or an options map. F
To pass an options map:
```go-html-template {file="layouts/_default/single.html"}
```go-html-template {file="layouts/page.html"}
{{ $opts := dict
"document" .
"indices" (slice "tags" "keywords")

View File

@@ -36,7 +36,7 @@ content/
With the structure above, we can range through page resources of type `page` to build content:
```go-html-template {file="layouts/lessons/single.html"}
```go-html-template {file="layouts/lessons/page.html"}
{{ range .Resources.ByType "page" }}
{{ .Content }}
{{ end }}

View File

@@ -24,7 +24,7 @@ This shortcode call uses positional arguments:
To retrieve arguments by position:
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
```
@@ -38,7 +38,7 @@ This shortcode call uses named arguments:
To retrieve arguments by name:
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.
```

View File

@@ -19,7 +19,7 @@ We design the **best** widgets in the world.
With this shortcode:
```go-html-template {file="layouts/shortcodes/card.html"}
```go-html-template {file="layouts/_shortcodes/card.html"}
<div class="card">
{{ with .Get "title" }}
<div class="card-title">{{ . }}</div>
@@ -51,7 +51,7 @@ Is rendered to:
Let's modify the example above to pass the value returned by `Inner` through the [`RenderString`] method on the `Page` object:
```go-html-template {file="layouts/shortcodes/card.html"}
```go-html-template {file="layouts/_shortcodes/card.html"}
<div class="card">
{{ with .Get "title" }}
<div class="card-title">{{ . }}</div>
@@ -98,7 +98,7 @@ This configuration is not unsafe if _you_ control the content. Read more about H
Second, because we are rendering the entire shortcode as Markdown, we must adhere to the rules governing [indentation] and inclusion of [raw HTML blocks] as provided in the [CommonMark] specification.
```go-html-template {file="layouts/shortcodes/card.html"}
```go-html-template {file="layouts/_shortcodes/card.html"}
<div class="card">
{{ with .Get "title" }}
<div class="card-title">{{ . }}</div>
@@ -113,8 +113,8 @@ Second, because we are rendering the entire shortcode as Markdown, we must adher
The difference between this and the previous example is subtle but required. Note the change in indentation, the addition of a blank line, and removal of the `RenderString` method.
```diff
--- layouts/shortcodes/a.html
+++ layouts/shortcodes/b.html
--- layouts/_shortcodes/a.html
+++ layouts/_shortcodes/b.html
@@ -1,8 +1,9 @@
<div class="card">
{{ with .Get "title" }}
@@ -137,7 +137,7 @@ The difference between this and the previous example is subtle but required. Not
[`strings.TrimSpace`]: /functions/strings/trimspace/
[CommonMark]: https://spec.commonmark.org/current/
[details]: /methods/page/renderstring/
[indentation]: https://spec.commonmark.org/0.30/#indented-code-blocks
[indentation]: https://spec.commonmark.org/current/#indented-code-blocks
[Markdown notation]: /content-management/shortcodes/#notation
[raw HTML blocks]: https://spec.commonmark.org/0.31.2/#html-blocks
[raw HTML blocks]: https://spec.commonmark.org/current/#html-blocks
[security model]: /about/security/

View File

@@ -35,7 +35,7 @@ In the example above, notice that the content between the opening and closing sh
With this shortcode, calling `Inner` instead of `InnerDeindent`:
```go-html-template {file="layouts/shortcodes/gallery.html"}
```go-html-template {file="layouts/_shortcodes/gallery.html"}
<div class="gallery">
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
@@ -66,7 +66,7 @@ Hugo renders the Markdown to:
Although technically correct per the CommonMark specification, this is not what we want. If we remove the indentation using the `InnerDeindent` method:
```go-html-template {file="layouts/shortcodes/gallery.html"}
```go-html-template {file="layouts/_shortcodes/gallery.html"}
<div class="gallery">
{{ .InnerDeindent | strings.TrimSpace | .Page.RenderString }}
</div>
@@ -94,5 +94,5 @@ Hugo renders the Markdown to:
```
[commonmark]: https://commonmark.org/
[indentation]: https://spec.commonmark.org/0.30/#indented-code-blocks
[indentation]: https://spec.commonmark.org/current/#indented-code-blocks
[`Inner`]: /methods/shortcode/inner/

View File

@@ -13,7 +13,7 @@ To support both positional and named arguments when calling a shortcode, use the
With this shortcode template:
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ if .IsNamedParams }}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }}
{{ else }}

View File

@@ -11,7 +11,7 @@ params:
The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ $greeting := "" }}
{{ with .Get "greeting" }}
{{ $greeting = . }}

View File

@@ -24,7 +24,7 @@ This method is useful for, among other things, assigning unique element IDs when
This shortcode performs error checking, then renders an HTML `img` element with a unique `id` attribute:
```go-html-template {file="layouts/shortcodes/img.html"}
```go-html-template {file="layouts/_shortcodes/img.html"}
{{ $src := "" }}
{{ with .Get "src" }}
{{ $src = . }}

View File

@@ -26,7 +26,7 @@ Calling this shortcode:
We can access the front matter values using the `Page` method:
```go-html-template {file="layouts/shortcodes/book-details.html"}
```go-html-template {file="layouts/_shortcodes/book-details.html"}
<ul>
<li>Title: {{ .Page.Title }}</li>
<li>Author: {{ .Page.Params.author }}</li>

View File

@@ -15,7 +15,7 @@ When you call a shortcode using positional arguments, the `Params` method return
{{</* myshortcode "Hello" "world" */>}}
```
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ index .Params 0 }} → Hello
{{ index .Params 1 }} → world
```
@@ -26,7 +26,7 @@ When you call a shortcode using named arguments, the `Params` method returns a m
{{</* myshortcode greeting="Hello" name="world" */>}}
```
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ .Params.greeting }} → Hello
{{ .Params.name }} → world
```

View File

@@ -19,13 +19,13 @@ Welcome. Today is {{</* now */>}}.
{{</* /greeting */>}}
```
```go-html-template {file="layouts/shortcodes/greeting.html"}
```go-html-template {file="layouts/_shortcodes/greeting.html"}
<div class="greeting">
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
```
```go-html-template {file="layouts/shortcodes/now.html"}
```go-html-template {file="layouts/_shortcodes/now.html"}
{{- $dateFormat := "January 2, 2006 15:04:05" }}
{{- with .Params }}

View File

@@ -11,7 +11,7 @@ params:
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
```go-html-template {file="layouts/shortcodes/myshortcode.html"}
```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
{{ $greeting := "" }}
{{ with .Get "greeting" }}
{{ $greeting = . }}

Some files were not shown because too many files have changed in this diff Show More