Site variables
All methods
Use any of these methods in your templates.
- .Site.AllPages
- Returns a collection of all pages in all languages.
- .Site.BaseURL
- Returns the base URL as defined in the site configuration.
- .Site.BuildDrafts
- Reports whether the current build includes draft pages.
- .Site.Config
- Returns a subset of the site configuration.
- .Site.Copyright
- Returns the copyright notice as defined in the site configuration.
- .Site.Data
- Returns a data structure composed from the files in the data directory.
- .Site.GetPage
- Returns a Page object from the given path.
- .Site.Home
- Returns the home Page object for the given site.
- .Site.IsMultiLingual
- Reports whether the site is multilingual.
- .Site.Language
- Returns the language object for the given site.
- .Site.LanguagePrefix
- Returns the URL language prefix, if any, for the given site.
- .Site.Languages
- Returns a collection of language objects for all sites, ordered by language weight.
- .Site.LastChange
- Returns the last modification date of site content.
- .Site.MainSections
- Returns a slice of the main section names as defined in the site configuration, falling back to the top level section with the most pages.
- Returns a collection of menu objects for the given site.
- .Site.Pages
- Returns a collection of all pages.
- .Site.Param
- Returns the site parameter with the given key.
- .Site.Params
- Returns a map of custom parameters as defined in the site configuration.
- .Site.RegularPages
- Returns a collection of all regular pages.
- .Site.Sections
- Returns a collection of first level section pages.
- .Site.Sites
- Returns a collection of all Site objects, one for each language, ordered by language weight.
- .Site.Taxonomies
- Returns a data structure containing the site’s taxonomy objects, the terms within each taxonomy object, and the pages to which the terms are assigned.
- .Site.Title
- Returns the title as defined in the site configuration.
Multilingual
Use these methods with your multilingual projects.
- .Site.IsMultiLingual
- Reports whether the site is multilingual.
- .Site.Language
- Returns the language object for the given site.
- .Site.LanguagePrefix
- Returns the URL language prefix, if any, for the given site.
- .Site.Languages
- Returns a collection of language objects for all sites, ordered by language weight.
Page collections
Range through these collections when rendering lists on any page.
- .Site.Pages
- Returns a collection of all pages.
- .Site.RegularPages
- Returns a collection of all regular pages.
- .Site.Sections
- Returns a collection of first level section pages.
Global site function
Within a partial template, if you did not pass a Page
or Site
object in context, you cannot use this syntax:
{{ .Site.SomeMethod }}
Instead, use the global site
function:
{{ site.SomeMethod }}