2017-08-10 11:18:22 -04:00
---
title: Site Variables
linktitle: Site Variables
description: 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.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [variables and params]
2017-09-21 13:03:00 -04:00
keywords: [global,site]
2017-08-10 11:18:22 -04:00
draft: false
menu:
docs:
parent: "variables"
weight: 10
weight: 10
sections_weight: 10
aliases: [/variables/site-variables/]
toc: true
---
The following is a list of site-level (aka "global") variables. Many of these variables are defined in your site's [configuration file][config], whereas others are built into Hugo's core for convenient usage in your templates.
## Site Variables List
2017-12-30 03:15:31 -05:00
.Site.AllPages
2017-08-10 11:18:22 -04:00
: array of all pages, regardless of their translation.
2017-12-30 03:15:31 -05:00
.Site.Author
2017-08-10 11:18:22 -04:00
: a map of the authors as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.BaseURL
2017-08-10 11:18:22 -04:00
: the base URL for the site as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.BuildDrafts
2017-08-10 11:18:22 -04:00
: a boolean (default: `false` ) to indicate whether to build drafts as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.Copyright
2017-08-10 11:18:22 -04:00
: a string representing the copyright of your website as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.Data
2017-08-10 11:18:22 -04:00
: custom data, see [Data Templates ](/templates/data-templates/ ).
2017-12-30 03:15:31 -05:00
.Site.DisqusShortname
2017-08-10 11:18:22 -04:00
: a string representing the shortname of the Disqus shortcode as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.Files
2017-08-10 11:18:22 -04:00
: all source files for the Hugo website.
2017-12-30 03:15:31 -05:00
.Site.GoogleAnalytics
2017-08-10 11:18:22 -04:00
: a string representing your tracking code for Google Analytics as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.IsMultiLingual
2017-08-10 11:18:22 -04:00
: whether there are more than one language in this site. See [Multilingual ](/content-management/multilingual/ ) for more information.
2017-12-30 03:15:31 -05:00
.Site.Language.Lang
2017-08-10 11:18:22 -04:00
: the language code of the current locale (e.g., `en` ).
2017-12-30 03:15:31 -05:00
.Site.Language.LanguageName
2017-08-10 11:18:22 -04:00
: the full language name (e.g. `English` ).
2017-12-30 03:15:31 -05:00
.Site.Language.Weight
2017-08-10 11:18:22 -04:00
: the weight that defines the order in the `.Site.Languages` list.
2017-12-30 03:15:31 -05:00
.Site.Language
2017-08-10 11:18:22 -04:00
: indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition.
2017-12-30 03:15:31 -05:00
.Site.LanguageCode
2017-08-10 11:18:22 -04:00
: 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.
2017-12-30 03:15:31 -05:00
.Site.LanguagePrefix
2017-08-10 11:18:22 -04:00
: 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 ](/functions/abslangurl/ ) and [relLangURL ](/functions/rellangurl ).
2017-12-30 03:15:31 -05:00
.Site.Languages
2017-08-10 11:18:22 -04:00
: an ordered list (ordered by defined weight) of languages.
2017-12-30 03:15:31 -05:00
.Site.LastChange
2017-08-10 11:18:22 -04:00
: 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 ](/content-management/front-matter ) of your content pages.
2017-12-30 03:15:31 -05:00
.Site.Menus
2017-08-10 11:18:22 -04:00
: all of the menus in the site.
2017-12-30 03:15:31 -05:00
.Site.Pages
2017-08-10 11:18:22 -04:00
: array of all content ordered by Date with the newest first. This array contains only the pages in the current language.
2017-12-30 03:15:31 -05:00
.Site.Permalinks
2017-08-10 11:18:22 -04:00
: a string to override the default [permalink ](/content-management/urls/ ) format as defined in the site configuration.
2017-12-30 03:15:31 -05:00
.Site.RegularPages
2017-08-10 11:18:22 -04:00
: a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"` .
2017-12-30 03:15:31 -05:00
.Site.RSSLink
2017-08-10 11:18:22 -04:00
: the URL for the site RSS.
2017-12-30 03:15:31 -05:00
.Site.Sections
2017-08-10 11:18:22 -04:00
: top-level directories of the site.
2017-12-30 03:15:31 -05:00
.Site.Taxonomies
2017-08-10 11:18:22 -04:00
: the [taxonomies ](/taxonomies/usage/ ) for the entire site. Replaces the now-obsolete `.Site.Indexes` since v0.11. Also see section [Taxonomies elsewhere ](#taxonomies-elsewhere ).
2017-12-30 03:15:31 -05:00
.Site.Title
2017-08-10 11:18:22 -04:00
: 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.toml` defines a site-wide param for `description` :
```
baseURL = "https://yoursite.example.com/"
[params]
description = "Tesla's Awesome Hugo Site"
author = "Nikola Tesla"
```
You can use `.Site.Params` in a [partial template ](/templates/partials/ ) to call the default site description:
{{< code file = "layouts/partials/head.html" > }}
< meta name = "description" content = "{{if .IsHome}}{{ $.Site.Params.description }}{{else}}{{.Description}}{{end}}" / >
{{< / code > }}
[config]: /getting-started/configuration/