32cb8785e Fix page weights in content management section (#1896) 11977b96f Make relURL and related functions consistent (#1895) f12180207 Clarify github deployment (#1894) 958877789 Remove remaining references to Highlight.js (#1893) fc487d263 Minor edit to taxonomy page 3b6a224b2 Update theme b28553b62 Change "flavor" to "edition" when referring to builds (#1892) 660e7581c Replaced sudo in OpenBSD with doas (#1891) e3fcdea10 fix a few minor grammatical issues on Firebase docs (#1889) e4c8b30eb update Static Web Apps docs (#1890) da2197c9e Update hosting-on-firebase.md (#1347) 5f2a0c271 Adding deployment guide for Azure Static Web Apps (#1456) 5aaf570cd add Azure Static Web App config to 404 template 35fc54362 add Azure Static Web App config to 404 template d48f67ba1 Update 01-flavors.md 11debae8d Cleaned Use of ref and relref section, added refs of index.md and _in… (#1744) b77604078 docs: Add link to menu entry variables (#1827) 0fa8a6bf0 Misc copy edits (#1887) c27b545ac Improve explanation of safeHTMLAttr's function (#1503) b04a4b32e Make CLI command summaries meaningful (#1886) dbf00a81f Fix a typo in diagrams documentation (#1885) 11f884327 docs: Clarify how to remove draft/future/expired content (#1831) 6dc9e9860 Improve complement function (#1884) 56448a51a Remove erroneous sourcemap desc (#1883) a0d0d2829 Merge branch 'divinerites-patch-1' 10f20cb5e Add a plausible-hugo theme component 9f1413eb5 Minor edits to showcase example 7d78420db fix broken link to Isso Comments 925cb291f Make directory tree consistent with other examples 300fff092 Add link to security policy from getenv.md (#1746) 7b4c517a6 Fix docs menu weights ce35775e0 Update faq.md (#1763) f3fb791a4 Remove dated new-in flags (#1879) b6c634629 Remove deprecated templating langs (#1880) 1b25ca34f Update the findRE and replaceRE functions (#1881) 28757ec73 Add Alora Labs website to showcase (#1494) e3c4bc4e7 Remove unimplemented "ugly" property 86afd84ff Update editors.md (#1878) 44c093911 Add urlquery function docs (#1633) 16a8c3548 Update links to installation page (#1876) 9e357f078 Add missing sections to BSD installation page (#1875) 1b1291634 Promote "Installation" to a section 9dd51235b Add detail to description of .Plain page variable (#1870) d333d0287 Minor markdown linting fix and URL updates (#1873) d57c8aa50 Remove extraneous apostrophe (#1871) 8c25cfc5c Update index.md 09fea41e0 Add lang to fenced code block 35b904798 Add small documentation about .Site.Social.twitter variable (#1854) 672042f89 Consolidate site configuration dfd4dd873 Add help.ampio.com showcase. (#1863) e8d0e7bdf Include link to internal templates code (#1794) 7db6f0c01 Add example to split function (#1867) be87dba80 Clarify split function docs (#1792) a079193f1 Fix typo on data templates page b234c70ee Fix data templates page (#1855) 074232b45 Update front-matter.md (#1856) 711c8fa80 Added missing default value (#1862) 034762882 Fixed some grammar issues and typos (#1865) 764574a4d Fix spelling error 2698f2d44 update URLs to prevent redirects (#1864) 68f05fdc8 Fenced code blocks should have a language specified (#1861) 24393315b GitHub Workflows security hardening (#1859) 3eeee13bf Markdown formatting: Add Fenced code block languages (#1858) e152cdf1f netlify: Hugo 0.105.0 4c7fc9f7e Merge branch 'tempv0.105.0' d16710afc Change anchor reference to use relref function calls (#1853) f52af8e4a tpl/encoding: Add noHTMLEscape option to jsonify eca0046c4 Update hosting-on-keycdn docs (#1852) ffbe17a48 Add note for rsync deploy command (#1415) c482133f1 docs: Update quick start to clarify the need of extended version (#1828) 1e3b33804 use correct URL for Google Search console verification (#1851) dac034f63 Markdown and formatting fixes (#1850) 43f177e3c Fix LiveReload in quick-start (#1739) f78deaa5f Add link for ''Hugo Shortcode Syntax Highlighting' VS Code extension (#1765) 08087ecd7 Remove some hidden pages (#1848) b6cb5ae48 Markdown linting fixes (#1846) 527ec5941 Update hugo.md (#1742) 83e8f2168 Clarify that a shortcode with .Inner must be closed (#1785) 4193f4445 Add Super Linter GitHub Action (#1845) fd91bfe1a Formatting and grammar fixes (#1844) ab5a49c49 Create codeql-analysis GitHub Action (#1812) 63b3e082e Add tutorial on using fusejs to search examples (#1756) 54c253ab0 Note that Google Universal Analytics are deprecated (#1770) 385fa77c6 Update articles.toml (#1840) 5e336bd26 Replace awkward wording (ESL?) (#1842) 2446ad349 Added Introduction to Hugo tutorial/video series (#1736) 7b21b2e76 Don't use self-closing generator tag ef73712ff Image processing. available methods: add method 'Colors' (#1837) 018f83bbe [comment platform] - add new alternative (#1751) 5636c208b Grammar and spelling fixes (#1836) 3f2e26f77 Change link of repojacking vulnerable link - JekyllToHugo (#1834) 301379fc3 fix: use shorter image URL to make it easier to read (#1835) de5fa7b30 Update search.md to include Pagefind (#1826) e9d72bcda Breadcrumb example: add basic accessibility (#1832) 6cffff87a netlify: Hugo 0.104.3 892360f61 Update output-formats.md 09a7a46ae Remove my defunct and little used migrator (#1824) 347434cca netlify: Hugo 0.104.2 f8c721162 Update postcss.md c2baf7155 netlify: Hugo 0.104.1 05d1192cd Update diagrams.md (#1823) 3c43a8bbe netlify: Hugo 0.104.0 57973b334 Merge branch 'tempv0.104.0' da775a36d docs: Regen docs helper ae48b5901 docs: Regenerate CLI docs af4a823b1 resources/images: Add $image.Colors 8e3f9ca64 Remove outdated IE conditional comments example (#1821) d1a84701b fix typo in template introduction (#1820) c0c7339e0 Update internal.md 17aefc515 Remove the recommendation about where to put the GA tempalte 263297236 Adjust GA template instructions 1cc265d99 Update the GA template usage section e11968338 config/security: Allow proxy variables in subcommands 9218ab993 netlify: Hugo 0.103.1 0b0e890d1 Update markdownify and RenderString documentation (#1818) 50f5d4776 Fix internal link (#1817) 6beb443c5 netlify: Hugo 0.103.0 14b5af248 Merge branch 'tempv0.103.0' 548e7aa62 server: Add 404 support 3a20aa0ba Update theme git-subtree-dir: docs git-subtree-split: 32cb8785ea74d5b82f2e2bea79d059cab497902a
10 KiB
title | linkTitle | description | lastmod | categories | keywords | menu | toc | weight | aliases | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Front Matter | Front Matter | Hugo allows you to add front matter in yaml, toml, or json to your content files. | 2017-02-24 |
|
|
|
true | 60 |
|
Front matter allows you to keep metadata attached to an instance of a content type---i.e., embedded inside a content file---and is one of the many features that gives Hugo its strength.
{{< youtube Yh2xKRJGff4 >}}
Front Matter Formats
Hugo supports four formats for front matter, each with their own identifying tokens.
- TOML
- identified by opening and closing
+++
. - YAML
- identified by opening and closing
---
. - JSON
- a single JSON object surrounded by '
{
' and '}
', followed by a new line. - ORG
- a group of Org mode keywords in the format '
#+KEY: VALUE
'. Any line that does not start with#+
ends the front matter section. Keyword values can be either strings (#+KEY: VALUE
) or a whitespace separated list of strings (#+KEY[]: VALUE_1 VALUE_2
).
Example
{{< code-toggle >}} title = "spf13-vim 3.0 release and new website" description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ] date = "2012-04-06" categories = [ "Development", "VIM" ] slug = "spf13-vim-3-0-release-and-new-website" {{< /code-toggle >}}
Front Matter Variables
Predefined
There are a few predefined variables that Hugo is aware of. See Page Variables for how to call many of these predefined variables in your templates.
- aliases
- an array of one or more aliases (e.g., old published paths of renamed content) that will be created in the output directory structure . See Aliases for details.
- audio
- an array of paths to audio files related to the page; used by the
opengraph
internal template to populateog:audio
. - cascade
- a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See Front Matter Cascade for details.
- date
- the datetime assigned to this page. This is usually fetched from the
date
field in front matter, but this behavior is configurable. - description
- the description for the content.
- draft
- if
true
, the content will not be rendered unless the--buildDrafts
flag is passed to thehugo
command. - expiryDate
- the datetime at which the content should no longer be published by Hugo; expired content will not be rendered unless the
--buildExpired
flag is passed to thehugo
command. - headless
- if
true
, sets a leaf bundle to be headless. - images
- an array of paths to images related to the page; used by internal templates such as
_internal/twitter_cards.html
. - isCJKLanguage
- if
true
, Hugo will explicitly treat the content as a CJK language; both.Summary
and.WordCount
work properly in CJK languages. - keywords
- the meta keywords for the content.
- layout
- the layout Hugo should select from the lookup order when rendering the content. If a
type
is not specified in the front matter, Hugo will look for the layout of the same name in the layout directory that corresponds with a content's section. See Content Types. - lastmod
- the datetime at which the content was last modified.
- linkTitle
- used for creating links to content; if set, Hugo defaults to using the
linktitle
before thetitle
. Hugo can also order lists of content bylinktitle
. - markup
- experimental; specify
"rst"
for reStructuredText (requiresrst2html
) or"md"
(default) for Markdown. - outputs
- allows you to specify output formats specific to the content. See output formats.
- publishDate
- if in the future, content will not be rendered unless the
--buildFuture
flag is passed tohugo
. - resources
- used for configuring page bundle resources. See Page Resources.
- series
- an array of series this page belongs to, as a subset of the
series
taxonomy; used by theopengraph
internal template to populateog:see_also
. - slug
- appears as the tail of the output URL. A value specified in front matter will override the segment of the URL based on the filename.
- summary
- text used when providing a summary of the article in the
.Summary
page variable; details available in the content-summaries section. - title
- the title for the content.
- type
- the type of the content; this value will be automatically derived from the directory (i.e., the section) if not specified in front matter.
- url
- the full path to the content from the web root. It makes no assumptions about the path of the content file. See URL Management.
- videos
- an array of paths to videos related to the page; used by the
opengraph
internal template to populateog:video
. - weight
- used for ordering your content in lists. Lower weight gets higher precedence. So content with lower weight will come first. If set, weights should be non-zero, as 0 is interpreted as an unset weight.
- <taxonomies>
- field name of the plural form of the index. See
tags
andcategories
in the above front matter examples. Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.
{{% note "Hugo's Default URL Destinations" %}}
If neither slug
nor url
is present and permalinks are not configured otherwise in your site config
file, Hugo will use the filename of your content to create the output URL. See Content Organization for an explanation of paths in Hugo and URL Management for ways to customize Hugo's default behaviors.
{{% /note %}}
User-Defined
You can add fields to your front matter arbitrarily to meet your needs. These user-defined key-values are placed into a single .Params
variable for use in your templates.
The following fields can be accessed via .Params.include_toc
and .Params.show_comments
, respectively. The Variables section provides more information on using Hugo's page- and site-level variables in your templates.
{{< code-toggle copy="false" >}} include_toc: true show_comments: false {{</ code-toggle >}}
Front Matter Cascade
Any node or section can pass down to descendants a set of Front Matter values as long as defined underneath the reserved cascade
Front Matter key.
Target Specific Pages
The cascade
block can be a slice with a optional _target
keyword, allowing for multiple cascade
values targeting different page sets.
{{< code-toggle copy="false" >}} title ="Blog" cascade background = "yosemite.jpg" [cascade._target] path="/blog/**" lang="en" kind="page" cascade background = "goldenbridge.jpg" [cascade._target] kind="section" {{</ code-toggle >}}
Keywords available for _target
:
- path
- A Glob pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. The matching supports double-asterisks so you can match for patterns like
/blog/*/**
to match anything from the third level and down. - kind
- A Glob pattern matching the Page's Kind(s), e.g. "{home,section}".
- lang
- A Glob pattern matching the Page's language, e.g. "{en,sv}".
- environment
- A Glob pattern matching the build environment, e.g. "{production,development}"
Any of the above can be omitted.
Example
In content/blog/_index.md
{{< code-toggle copy="false" >}} title: Blog cascade: banner: images/typewriter.jpg {{</ code-toggle >}}
With the above example the Blog section page and its descendants will return images/typewriter.jpg
when .Params.banner
is invoked unless:
- Said descendant has its own
banner
value set - Or a closer ancestor node has its own
cascade.banner
value set.
Order Content Through Front Matter
You can assign content-specific weight
in the front matter of your content. These values are especially useful for ordering in list views. You can use weight
for ordering of content and the convention of <TAXONOMY>_weight
for ordering content within a taxonomy. See Ordering and Grouping Hugo Lists to see how weight
can be used to organize your content in list views.
Override Global Markdown Configuration
It's possible to set some options for Markdown rendering in a content's front matter as an override to the Rendering options set in your project configuration.