github.com/rabbouni145/gg@v0.47.1/docs/content/en/templates/lookup-order.md (about) 1 --- 2 title: Hugo's Lookup Order 3 linktitle: Template Lookup Order 4 description: Hugo searches for the layout to use for a given page in a well defined order, starting from the most specific. 5 godocref: 6 date: 2017-02-01 7 publishdate: 2017-02-01 8 lastmod: 2017-07-05 9 categories: [templates,fundamentals] 10 keywords: [templates] 11 menu: 12 docs: 13 parent: "templates" 14 weight: 15 15 quicklinks: 16 weight: 15 17 sections_weight: 15 18 draft: false 19 aliases: [/templates/lookup/] 20 toc: true 21 --- 22 23 ## Hugo Layouts Lookup Rules 24 25 Hugo takes the parameters listed below into consideration when choosing a layout for a given page. They are listed in a priority order. This should feel natural, but look at the table below for concrete examples of the different parameter variations. 26 27 28 Kind 29 : The page `Kind` (the home page is one). See the example tables below per kind. This also determines if it is a **single page** (i.e. a regular content page. We then look for a template in `_default/single.html` for HTML) or a **list page** (section listings, home page, taxonomy lists, taxonomy terms. We then look for a template in `_default/list.html` for HTML). 30 31 Output Format 32 : See [Custom Output Formats](/templates/output-formats). An output format has both a `name` (e.g. `rss`, `amp`, `html`) and a `suffix` (e.g. `xml`, `html`). We prefer matches with both (e.g. `index.amp.html`, but look for less specific templates. 33 34 Language 35 : We will consider a language code in the template name. If the site language is `fr`, `index.fr.amp.html` will win over `index.amp.html`, but `index.amp.html` will be chosen before `index.fr.html`. 36 37 Layout 38 : Can be set in page front matter. 39 40 Type 41 : Is value of `type` if set in front matter, else it is the name of the root section (e.g. "blog"). It will always have a value, so if not set, the value is "page". 42 43 Section 44 : Is relevant for `section`, `taxonomy` and `taxonomyTerm` types. 45 46 {{% note %}} 47 **Tip:** The examples below looks long and complex. That is the flexibility talking. Most Hugo sites contain just a handful of templates: 48 49 ```bash 50 ├── _default 51 │ ├── baseof.html 52 │ ├── list.html 53 │ └── single.html 54 └── index.html 55 ``` 56 {{% /note %}} 57 58 59 ## Hugo Layouts Lookup Rules With Theme 60 61 In Hugo, layouts can live in either the project's or the themes' layout folders, and the most specific layout will be chosen. Hugo will interleave the lookups listed below, finding the most specific one either in the project or themes. 62 63 ## Examples: Layout Lookup for Regular Pages 64 65 {{< datatable-filtered "output" "layouts" "Kind == page" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} 66 67 ## Examples: Layout Lookup for Home Page 68 69 {{< datatable-filtered "output" "layouts" "Kind == home" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} 70 71 ## Examples: Layout Lookup for Section Pages 72 73 {{< datatable-filtered "output" "layouts" "Kind == section" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} 74 75 ## Examples: Layout Lookup for Taxonomy List Pages 76 77 {{< datatable-filtered "output" "layouts" "Kind == taxonomy" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} 78 79 ## Examples: Layout Lookup for Taxonomy Terms Pages 80 81 {{< datatable-filtered "output" "layouts" "Kind == taxonomyTerm" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} 82 83 84 85