github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/content/en/variables/site.md (about) 1 --- 2 title: Site Variables 3 linktitle: Site Variables 4 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. 5 date: 2017-02-01 6 publishdate: 2017-02-01 7 lastmod: 2017-02-01 8 categories: [variables and params] 9 keywords: [global,site] 10 draft: false 11 menu: 12 docs: 13 parent: "variables" 14 weight: 10 15 weight: 10 16 sections_weight: 10 17 aliases: [/variables/site-variables/] 18 toc: true 19 --- 20 21 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. 22 23 ## Site Variables List 24 25 .Site.AllPages 26 : array of all pages, regardless of their translation. 27 28 .Site.Author 29 : a map of the authors as defined in the site configuration. 30 31 .Site.BaseURL 32 : the base URL for the site as defined in the site configuration. 33 34 .Site.BuildDrafts 35 : a boolean (default: `false`) to indicate whether to build drafts as defined in the site configuration. 36 37 .Site.Copyright 38 : a string representing the copyright of your website as defined in the site configuration. 39 40 .Site.Data 41 : custom data, see [Data Templates](/templates/data-templates/). 42 43 .Site.DisqusShortname 44 : a string representing the shortname of the Disqus shortcode as defined in the site configuration. 45 46 .Site.Files 47 : all source files for the Hugo website. 48 49 .Site.GoogleAnalytics 50 : a string representing your tracking code for Google Analytics as defined in the site configuration. 51 52 .Site.IsMultiLingual 53 : whether there are more than one language in this site. See [Multilingual](/content-management/multilingual/) for more information. 54 55 .Site.IsServer 56 : a boolean to indicate if the site is being served with Hugo's built-in server. See [`hugo server`](/commands/hugo_server/) for more information. 57 58 .Site.Language.Lang 59 : the language code of the current locale (e.g., `en`). 60 61 .Site.Language.LanguageName 62 : the full language name (e.g. `English`). 63 64 .Site.Language.Weight 65 : the weight that defines the order in the `.Site.Languages` list. 66 67 .Site.Language 68 : indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition. 69 70 .Site.LanguageCode 71 : 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. 72 73 .Site.LanguagePrefix 74 : 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). 75 76 .Site.Languages 77 : an ordered list (ordered by defined weight) of languages. 78 79 .Site.LastChange 80 : 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. 81 82 .Site.Menus 83 : all of the menus in the site. 84 85 .Site.Pages 86 : array of all content ordered by Date with the newest first. This array contains only the pages in the current language. 87 88 .Site.Permalinks 89 : a string to override the default [permalink](/content-management/urls/) format as defined in the site configuration. 90 91 .Site.RegularPages 92 : a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"`. 93 94 .Site.RSSLink 95 : the URL for the site RSS. 96 97 .Site.Sections 98 : top-level directories of the site. 99 100 .Site.Taxonomies 101 : the [taxonomies](/taxonomies/usage/) for the entire site. Replaces the now-obsolete `.Site.Indexes` since v0.11. Also see section [Taxonomies elsewhere](#taxonomies-elsewhere). 102 103 .Site.Title 104 : a string representing the title of the site. 105 106 ## The `.Site.Params` Variable 107 108 `.Site.Params` is a container holding the values from the `params` section of your site configuration. 109 110 ### Example: `.Site.Params` 111 112 The following `config.[yaml|toml|json]` defines a site-wide param for `description`: 113 114 {{< code-toggle file="config" >}} 115 baseURL = "https://yoursite.example.com/" 116 117 [params] 118 description = "Tesla's Awesome Hugo Site" 119 author = "Nikola Tesla" 120 {{</ code-toggle >}} 121 122 You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description: 123 124 {{< code file="layouts/partials/head.html" >}} 125 <meta name="description" content="{{if .IsHome}}{{ $.Site.Params.description }}{{else}}{{.Description}}{{end}}" /> 126 {{< /code >}} 127 128 [config]: /getting-started/configuration/