hugo/content/variables/site.md
Bjørn Erik Pedersen 047c4188df Squashed 'docs/' changes from d9c8fc220..f9a5dc59b
f9a5dc59b Code Toggle block added to doc site final batch Templates  Variables 
4d4107968 Add eSolia as new sponsor
000fed94e Add missing closing tags for li in menu template example
f462b620f Clarify that local CSV files cannot be inside data dir
ae083641a Added hugo-search-index to list of search tools
e2b64d0b7 Remove extra link
2fb4c9af5 Release 0.38.2
59b1c9853 releaser: Prepare repository for 0.39-DEV
92f6a05ea releaser: Add release notes to /docs for release of 0.38.2
76244729e releaser: Bump versions for release of 0.38.2
0960c5fb3 Adjust gray color of tab vs pane in code-toggle.
8ae3aadd7 use code-toggle shortcode when relevant Content Management 
455b8b53b Update related.md
6e8d19090 Release 0.38.1
079ba044c releaser: Prepare repository for 0.39-DEV
6f23e6ec1 releaser: Add release notes to /docs for release of 0.38.1
c51692ceb releaser: Bump versions for release of 0.38.1
d37ea6a5e Update related.md
faa2707d0 Update index.md
9ce901dcb Add a forgotten language tag (go-html-template) for code
b05aaed14 Update where.md
4d4760819 Fix typo in code-toggle.md
c5a5250a1 Use the new go-html-template Chroma lexer
2de831f4b Add the full list of Chroma lexers
18114d4b4 Update Output Formats
b069d7f84 Release 0.38
caaa8355a releaser: Prepare repository for 0.39-DEV
e45b7cc9f releaser: Add release notes to /docs for release of 0.38
40f40906e releaser: Bump versions for release of 0.38
2d52e2e4e Merge commit 'ed8bf081fdbf336e026517b7e1b123c039014ab5'
1439f64a0 docs: Generate docshelper data
5b0edfd79 Add .Site.IsServer
fdb579ad1 Merge commit '0a23baa6a90901f772c234107c4f12c16c76f4aa'
7b71da1f8 hugolib: Add Reset method to delete key from Scratch
63a131664 docs: Add docs for lang.Merge
55cba056d Merge commit '3886fc1fef6ac19d58b9ba1bb642d0c6c9a54031'
6f301ebcc docs: Add docs on the new front matter configuration
7ba35ef56 Merge commit 'c0290655825e7bb36e13fb39f89d85b392cf1adc'
3d2cab754 releaser: Prepare repository for 0.38-DEV
095e888e1 releaser: Add release notes to /docs for release of 0.37.1
593fa0dcb releaser: Bump versions for release of 0.37.1
c18c1df54 releaser: Prepare repository for 0.38-DEV

git-subtree-dir: docs
git-subtree-split: f9a5dc59b77d15cc2c7534e10bcd90bcfeda7bb4
2018-04-16 07:43:59 +02:00

4.5 KiB

title linktitle description date publishdate lastmod categories keywords draft menu weight sections_weight aliases toc
Site Variables Site Variables Many, but not all, site-wide variables are defined in your site's configuration. However, Hugo provides a number of built-in variables for convenient access to global values in your templates. 2017-02-01 2017-02-01 2017-02-01
variables and params
global
site
false
docs
parent weight
variables 10
10 10
/variables/site-variables/
true

The following is a list of site-level (aka "global") variables. Many of these variables are defined in your site's configuration file, whereas others are built into Hugo's core for convenient usage in your templates.

Site Variables List

.Site.AllPages
array of all pages, regardless of their translation.
.Site.Author
a map of the authors as defined in the site configuration.
.Site.BaseURL
the base URL for the site as defined in the site configuration.
.Site.BuildDrafts
a boolean (default: false) to indicate whether to build drafts as defined in the site configuration.
.Site.Copyright
a string representing the copyright of your website as defined in the site configuration.
.Site.Data
custom data, see Data Templates.
.Site.DisqusShortname
a string representing the shortname of the Disqus shortcode as defined in the site configuration.
.Site.Files
all source files for the Hugo website.
.Site.GoogleAnalytics
a string representing your tracking code for Google Analytics as defined in the site configuration.
.Site.IsMultiLingual
whether there are more than one language in this site. See Multilingual for more information.
.Site.IsServer
a boolean to indicate if the site is being served with Hugo's built-in server. See hugo server for more information.
.Site.Language.Lang
the language code of the current locale (e.g., en).
.Site.Language.LanguageName
the full language name (e.g. English).
.Site.Language.Weight
the weight that defines the order in the .Site.Languages list.
.Site.Language
indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition.
.Site.LanguageCode
a string representing the language as defined in the site configuration. This is mostly used to populate the RSS feeds with the right language code.
.Site.LanguagePrefix
this can be used to prefix URLs to point to the correct language. It will even work when only one defined language. See also the functions absLangURL and relLangURL.
.Site.Languages
an ordered list (ordered by defined weight) of languages.
.Site.LastChange
a string representing the date/time of the most recent change to your site. This string is based on the date variable in the front matter of your content pages.
.Site.Menus
all of the menus in the site.
.Site.Pages
array of all content ordered by Date with the newest first. This array contains only the pages in the current language.
.Site.Permalinks
a string to override the default permalink format as defined in the site configuration.
.Site.RegularPages
a shortcut to the regular page collection. .Site.RegularPages is equivalent to where .Site.Pages "Kind" "page".
.Site.RSSLink
the URL for the site RSS.
.Site.Sections
top-level directories of the site.
.Site.Taxonomies
the taxonomies for the entire site. Replaces the now-obsolete .Site.Indexes since v0.11. Also see section Taxonomies elsewhere.
.Site.Title
a string representing the title of the site.

The .Site.Params Variable

.Site.Params is a container holding the values from the params section of your site configuration.

Example: .Site.Params

The following config.[yaml|toml|json] defines a site-wide param for description:

{{< code-toggle file="config" >}} baseURL = "https://yoursite.example.com/"

[params] description = "Tesla's Awesome Hugo Site" author = "Nikola Tesla" {{</ code-toggle >}}

You can use .Site.Params in a partial template to call the default site description:

{{< code file="layouts/partials/head.html" >}}

{{< /code >}}