Page variables
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.
- 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.
- 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.