HUGO

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
gohugoio Star
  • About Hugo
    • Overview
    • What is Hugo
    • Hugo features
    • Static site generators
    • Hugo's security model
    • Hugo and the GDPR
    • License
  • Installation
    • Overview
    • macOS
    • Linux
    • Windows
    • BSD
  • Getting started
    • Overview
    • Quick start
    • Basic usage
    • Directory structure
    • Configuration
    • Configure markup
    • Glossary of terms
    • External learning resources
  • Content management
    • Overview
    • Organization
    • Page bundles
    • Content formats
    • Diagrams
    • Front matter
    • Build options
    • Page resources
    • Image processing
    • Shortcodes
    • Related content
    • Sections
    • Content types
    • Archetypes
    • Taxonomies
    • Summaries
    • Links and cross references
    • URL management
    • Menus
    • Static files
    • Table of contents
    • Comments
    • Multilingual
    • Syntax highlighting
    • Mathematics
  • Templates
    • Overview
    • Templating
    • Template lookup order
    • Base templates and blocks
    • Single page templates
    • List templates
    • Homepage template
    • Section templates
    • Taxonomy templates
    • Pagination
    • Content view templates
    • Partial templates
    • Shortcode templates
    • Menu templates
    • Data templates
    • RSS templates
    • Sitemap templates
    • Local file templates
    • Internal templates
    • Render hooks
    • Custom output formats
    • 404 page
    • Robots.txt
  • Functions
    • Overview
    • cast
    • collections
    • compare
    • crypto
    • data
    • debug
    • diagrams
    • encoding
    • fmt
    • global
    • go template
    • hugo
    • images
    • inflect
    • js
    • lang
    • math
    • openapi3
    • os
    • partials
    • path
    • reflect
    • resources
    • safe
    • strings
    • templates
    • time
    • transform
    • urls
  • Methods
    • Overview
    • Duration
    • Menu
    • Menu entry
    • Page
    • Pages
    • Resource
    • Shortcode
    • Site
    • Taxonomy
    • Time
  • Quick reference
    • Overview
    • Emojis
    • Functions
    • Methods
    • Page collections
  • Variables
    • Overview
    • File variables
    • Git variables
    • Menu entry variables
    • Page variables
    • Pages variables
    • Shortcode variables
    • Site variables
    • Taxonomy variables
  • Hugo Modules
    • Overview
    • Configure Hugo modules
    • Use Hugo Modules
    • Theme components
  • Hugo Pipes
    • Overview
    • Introduction
    • Transpile Sass to CSS
    • PostCSS
    • PostProcess
    • JavaScript building
    • Babel
    • Asset minification
    • Concatenating assets
    • Fingerprinting and SRI hashing
    • Resource from string
    • Resource from template
  • CLI
  • Troubleshooting
    • Overview
    • Audit
    • Logging
    • Inspection
    • Deprecation
    • Performance
    • FAQs
  • Developer tools
    • Overview
    • Editor plugins
    • Front-ends
    • Search
    • Migrations
    • Other projects
  • Hosting and deployment
    • Overview
    • Hugo Deploy
    • Deploy with Rclone
    • Deploy with Rsync
    • Host on 21YunBox
    • Host on AWS Amplify
    • Host on Azure Static Web Apps
    • Host on Cloudflare Pages
    • Host on Firebase
    • Host on GitHub Pages
    • Host on GitLab Pages
    • Host on KeyCDN
    • Host on Netlify
    • Host on Render
  • Contribute
    • Overview
    • Development
    • Documentation
    • Themes
  • Maintenance
VARIABLES

Page variables

Use these methods with a Page object.

We are making an effort to unify our terminology, and to use these terms consistently throughout the documentation.

Historically, we have inconsistently referred to the items on this page as functions, parameters, variables, or methods. They are not functions, parameters, or variables; they are methods.

This page will remain in place as readers become familiar with the unified terminology. See the methods section for a list of methods by object, or the methods quick reference guide.

All methods

Use any of these methods in your templates.

.Aliases
Returns the URL aliases as defined in front matter.
.AllTranslations
Returns all translation of the given page, including the given page.
.AlternativeOutputFormats
Returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page.
.Ancestors
Returns a collection of Page objects, one for each ancestor section of the given page.
.BundleType
Returns the bundle type of the given page, or an empty string if the page is not a page bundle.
.CodeOwners
Returns of slice of code owners for the given page, derived from the CODEOWNERS file in the root of the project directory.
.Content
Returns the rendered content of the given page.
.CurrentSection
Returns the Page object of the section in which the given page resides.
.Data
Returns a unique data object for each page kind.
.Date
Returns the date of the given page.
.Description
Returns the description of the given page as defined in front matter.
.Draft
Reports whether the given page is a draft as defined in front matter.
.Eq
Reports whether two Page objects are equal.
.ExpiryDate
Returns the expiry date of the given page.
.File
For pages backed by a file, returns file information for the given page.
.FirstSection
Returns the Page object of the top level section of which the given page is a descendant.
.Fragments
Returns a data structure of the fragments in the given page.
.FuzzyWordCount
Returns the number of words in the content of the given page, rounded up to the nearest multiple of 100.
.GetPage
Returns a Page object from the given path.
.GetTerms
Returns a collection of term pages for terms defined on the given page in the given taxonomy, ordered according to the sequence in which they appear in front matter.
.GitInfo
Returns Git information related to the last commit of the given page.
.HasMenuCurrent
Reports whether the given page object matches the page object associated with one of the child menu entries under the given menu entry in the given menu.
.HasShortcode
Reports whether the given shortcode is called by the given page.
.HeadingsFiltered
Returns a slice of headings for each page related to the given page.
.InSection
Reports whether the given page is in the given section.
.IsAncestor
Reports whether PAGE1 in an ancestor of PAGE2.
.IsDescendant
Reports whether PAGE1 in a descendant of PAGE2.
.IsHome
Reports whether the given page is the home page.
.IsMenuCurrent
Reports whether the given page object matches the page object associated with the given menu entry in the given menu.
.IsNode
Reports whether the given page is a node.
.IsPage
Reports whether the given page is a regular page.
.IsSection
Reports whether the given page is a section page.
.IsTranslated
Reports whether the given page has one or more translations.
.Keywords
Returns a slice of keywords as defined in front matter.
.Kind
Returns the kind of the given page.
.Language
Returns the language object for the given page.
.Lastmod
Returns the last modification date of the given page.
.Layout
Returns the layout for the given page as defined in front matter.
.Len
Returns the length, in bytes, of the rendered content of the given page.
.LinkTitle
Returns the link title of the given page.
.Next
Returns the next page in a global page collection, relative to the given page.
.NextInSection
Returns the next page within a section, relative to the given page.
.OutputFormats
Returns a slice of OutputFormat objects, each representing one of the output formats enabled for the given page.
.Page
Returns the Page object of the given page.
.Pages
Returns a collection of regular pages within the current section, and section pages of immediate descendant sections.
.Paginate
Paginates a collection of pages.
.Paginator
Paginates the collection of regular pages received in context.
.Param
Returns a page parameter with the given key, falling back to a site parameter if present.
.Params
Returns a map of custom parameters as defined in the front matter of the given page.
.Parent
Returns the Page object of the parent section of the given page.
.Permalink
Returns the permalink of the given page.
.Plain
Returns the rendered content of the given page, removing all HTML tags.
.PlainWords
Calls the Plain method, splits the result into a slice of words, and returns the slice.
.Prev
Returns the previous page in a global page collection, relative to the given page.
.PrevInSection
Returns the previous page within a section, relative to the given page.
.PublishDate
Returns the publish date of the given page.
.RawContent
Returns the raw content of the given page.
.ReadingTime
Returns the estimated reading time, in minutes, for the given page.
.Ref
Returns the absolute URL of the page with the given path, language, and output format.
.RegularPages
Returns a collection of regular pages within the current section.
.RegularPagesRecursive
Returns a collection of regular pages within the current section, and regular pages within all descendant sections.
.RelPermalink
Returns the relative permalink of the given page.
.RelRef
Returns the relative URL of the page with the given path, language, and output format.
.Render
Renders the given template with the given page as context.
.RenderShortcodes
Renders all shortcodes in the content of the given page, preserving the surrounding markup.
.RenderString
Renders markup to HTML.
.Resources
Returns a collection of page resources.
.Scratch
Creates a “scratch pad” on the given page to store and manipulate data.
.Section
Returns the name of the top level section in which the given page resides.
.Sections
Returns a collection of section pages, one for each immediate descendant section of the given page.
.Site
Returns the Site object.
.Sitemap
Returns the sitemap settings for the given page as defined in front matter, falling back to the sitemap settings as defined in the site configuration.
.Sites
Returns a collection of all Site objects, one for each language, ordered by language weight.
.Slug
Returns the URL slug of the given page as defined in front matter.
.Store
Creates a persistent “scratch pad” on the given page to store and manipulate data.
.Summary
Returns the content summary of the given page.
.TableOfContents
Returns a table of contents for the given page.
.Title
Returns the title of the given page.
.TranslationKey
Returns the translation key of the given page.
.Translations
Returns all translation of the given page, excluding the current language.
.Truncated
Reports whether the content length exceeds the summary length.
.Type
Returns the content type of the given page.
.Weight
Returns the weight of the given page as defined in front matter.
.WordCount
Returns the number of words in the content of the given page.

Dates

Use these methods to access content dates.

.Date
Returns the date of the given page.
.ExpiryDate
Returns the expiry date of the given page.
.Lastmod
Returns the last modification date of the given page.
.PublishDate
Returns the publish date of the given page.

Multilingual

Use these methods with your multilingual projects.

.AllTranslations
Returns all translation of the given page, including the given page.
.IsTranslated
Reports whether the given page has one or more translations.
.Language
Returns the language object for the given page.
.TranslationKey
Returns the translation key of the given page.
.Translations
Returns all translation of the given page, excluding the current language.

Navigation

Use these methods to create navigation links between pages.

.Next
Returns the next page in a global page collection, relative to the given page.
.NextInSection
Returns the next page within a section, relative to the given page.
.Prev
Returns the previous page in a global page collection, relative to the given page.
.PrevInSection
Returns the previous page within a section, relative to the given page.

Page collections

Range through these collections when rendering lists on section pages, taxonomy pages, term pages, and the home page.

.Pages
Returns a collection of regular pages within the current section, and section pages of immediate descendant sections.
.RegularPages
Returns a collection of regular pages within the current section.
.RegularPagesRecursive
Returns a collection of regular pages within the current section, and regular pages within all descendant sections.
.Sections
Returns a collection of section pages, one for each immediate descendant section of the given page.

Parameters

Use these methods to access page parameters.

.Param
Returns a page parameter with the given key, falling back to a site parameter if present.
.Params
Returns a map of custom parameters as defined in the front matter of the given page.

Sections

Use these methods to access section pages, and their ancestors and descendants. See details.

.Ancestors
Returns a collection of Page objects, one for each ancestor section of the given page.
.CurrentSection
Returns the Page object of the section in which the given page resides.
.FirstSection
Returns the Page object of the top level section of which the given page is a descendant.
.InSection
Reports whether the given page is in the given section.
.IsAncestor
Reports whether PAGE1 in an ancestor of PAGE2.
.IsDescendant
Reports whether PAGE1 in a descendant of PAGE2.
.Parent
Returns the Page object of the parent section of the given page.
.Section
Returns the name of the top level section in which the given page resides.
.Sections
Returns a collection of section pages, one for each immediate descendant section of the given page.

See also

  • Site variables
  • Pages variables
  • Multilingual mode

On this page

  • All methods
  • Dates
  • Multilingual
  • Navigation
  • Page collections
  • Parameters
  • Sections
Last updated: November 5, 2023: Miscellaneous updates (50866657)
Improve this page
By the Hugo Authors
Hugo Logo
  • File an Issue
  • Get Help
  • @GoHugoIO
  • @spf13
  • @bepsays

Netlify badge

 

Hugo Sponsors

 

The Hugo logos are copyright © Steve Francia 2013–2024.

The Hugo Gopher is based on an original work by Renée French.

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
  • About Hugo
  • Installation
  • Getting started
  • Content management
  • Templates
  • Functions
  • Methods
  • Quick reference
  • Variables
  • Hugo Modules
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Developer tools
  • Hosting and deployment
  • Contribute
  • Maintenance