github.com/rabbouni145/gg@v0.47.1/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.Home 53 : reference to the homepage's [page object](https://gohugo.io/variables/page/) 54 55 .Site.IsMultiLingual 56 : whether there are more than one language in this site. See [Multilingual](/content-management/multilingual/) for more information. 57 58 .Site.IsServer 59 : 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. 60 61 .Site.Language.Lang 62 : the language code of the current locale (e.g., `en`). 63 64 .Site.Language.LanguageName 65 : the full language name (e.g. `English`). 66 67 .Site.Language.Weight 68 : the weight that defines the order in the `.Site.Languages` list. 69 70 .Site.Language 71 : indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition. 72 73 .Site.LanguageCode 74 : 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. 75 76 .Site.LanguagePrefix 77 : 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). 78 79 .Site.Languages 80 : an ordered list (ordered by defined weight) of languages. 81 82 .Site.LastChange 83 : 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. 84 85 .Site.Menus 86 : all of the menus in the site. 87 88 .Site.Pages 89 : array of all content ordered by Date with the newest first. This array contains only the pages in the current language. See [`.Site.Pages`](#site-pages). 90 91 .Site.Permalinks 92 : a string to override the default [permalink](/content-management/urls/) format as defined in the site configuration. 93 94 .Site.RegularPages 95 : a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"`. See [`.Site.Pages`](#site-pages). 96 97 .Site.RSSLink 98 : the URL for the site RSS. 99 100 .Site.Sections 101 : top-level directories of the site. 102 103 .Site.Taxonomies 104 : the [taxonomies](/taxonomies/usage/) for the entire site. Replaces the now-obsolete `.Site.Indexes` since v0.11. Also see section [Taxonomies elsewhere](#taxonomies-elsewhere). 105 106 .Site.Title 107 : a string representing the title of the site. 108 109 ## The `.Site.Params` Variable 110 111 `.Site.Params` is a container holding the values from the `params` section of your site configuration. 112 113 ### Example: `.Site.Params` 114 115 The following `config.[yaml|toml|json]` defines a site-wide param for `description`: 116 117 {{< code-toggle file="config" >}} 118 baseURL = "https://yoursite.example.com/" 119 120 [params] 121 description = "Tesla's Awesome Hugo Site" 122 author = "Nikola Tesla" 123 {{</ code-toggle >}} 124 125 You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description: 126 127 {{< code file="layouts/partials/head.html" >}} 128 <meta name="description" content="{{if .IsHome}}{{ $.Site.Params.description }}{{else}}{{.Description}}{{end}}" /> 129 {{< /code >}} 130 131 ## The `.Site.Pages` Variable {#site-pages} 132 133 ### `.Site.Pages` compared to `.Pages` 134 135 {{< readfile file="/content/en/readfiles/pages-vs-site-pages.md" markdown="true" >}} 136 137 138 139 140 [config]: /getting-started/configuration/