More layout lookup work

Closes #400
This commit is contained in:
Bjørn Erik Pedersen 2018-03-09 13:31:48 +01:00
parent fe0ad9d9d4
commit e45b640f71
No known key found for this signature in database
GPG Key ID: 330E6E2BD4859D8F
3 changed files with 142 additions and 88 deletions

View File

@ -43,15 +43,7 @@ The idea of a list page comes from the [hierarchical mental model of the web][me
Since section lists and taxonomy lists (N.B., *not* [taxonomy terms lists][taxterms]) are both *lists* with regards to their templates, both have the same terminating default of `_default/list.html` or `themes/<THEME>/layouts/_default/list.html` in their lookup order. In addition, both [section lists][sectiontemps] and [taxonomy lists][taxlists] have their own default list templates in `_default`:
#### Default Section Templates
1. `layouts/_default/section.html`
2. `layouts/_default/list.html`
#### Default Taxonomy List Templates
1. `layouts/_default/taxonomy.html`
2. `themes/<THEME>/layouts/_default/taxonomy.html`
See [Template Lookup Order](/templates/lookup-order/) for the complete reference.
## Add Content and Front Matter to List Pages

View File

@ -20,7 +20,7 @@ toc: true
## RSS Template Lookup Order
See [Template Lookup](/templates/lookup-order/).
See [Template Lookup Order](/templates/lookup-order/) for the complete reference.
{{% note "Hugo Ships with an RSS Template" %}}
Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml). The embedded template will be sufficient for most use cases.
@ -28,7 +28,7 @@ Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml). The embedded
RSS pages are of the type `Page` and have all the [page variables](/variables/page/) available to use in the templates.
### Section RSS
### Section RSS!
A [sections][section] RSS will be rendered at `/<SECTION>/index.xml` (e.g., http://spf13.com/project/index.xml).
@ -36,27 +36,9 @@ Hugo provides the ability for you to define any RSS type you wish and can have d
## Lookup Order for RSS Templates
### Main RSS
The table below shows the RSS template lookup order for the different page kinds. The first listing shows the lookup order when running with a theme (`demoTheme`).
1. `/layouts/rss.xml`
2. `/layouts/_default/rss.xml`
3. Embedded rss.xml
### Section RSS
1. `/layouts/section/<SECTION>.rss.xml`
2. `/layouts/_default/rss.xml`
3. `/themes/<THEME>/layouts/section/<SECTION>.rss.xml`
4. `/themes/<THEME>/layouts/_default/rss.xml`
5. Embedded rss.xml
### Taxonomy RSS
1. `/layouts/taxonomy/<SINGULAR>.rss.xml`
2. `/layouts/_default/rss.xml`
3. `/themes/<THEME>/layouts/taxonomy/<SINGULAR>.rss.xml`
4. `/themes/<THEME>/layouts/_default/rss.xml`
5. Embedded rss.xml
{{< datatable-filtered "output" "layouts" "OutputFormat == RSS" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
## Configure RSS
@ -64,7 +46,7 @@ By default, Hugo will create an unlimited number of RSS entries. You can limit t
The following values will also be included in the RSS output if specified in your sites configuration:
```
```toml
languageCode = "en-us"
copyright = "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
@ -76,7 +58,7 @@ copyright = "This work is licensed under a Creative Commons Attribution-ShareAli
This is the default RSS template that ships with Hugo. It adheres to the [RSS 2.0 Specification][RSS 2.0].
```
```xml
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>

View File

@ -297,12 +297,6 @@
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
"layouts/page/index.html.html",
"layouts/page/home.html.html",
"layouts/page/list.html.html",
"layouts/page/index.html",
"layouts/page/home.html",
"layouts/page/list.html",
"layouts/index.html.html",
"layouts/home.html.html",
"layouts/list.html.html",
@ -349,14 +343,6 @@
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
"layouts/page/demolayout.html.html",
"layouts/page/index.html.html",
"layouts/page/home.html.html",
"layouts/page/list.html.html",
"layouts/page/demolayout.html",
"layouts/page/index.html",
"layouts/page/home.html",
"layouts/page/list.html",
"layouts/demolayout.html.html",
"layouts/index.html.html",
"layouts/home.html.html",
@ -381,18 +367,6 @@
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
"layouts/page/index.html.html",
"demoTheme/layouts/page/index.html.html",
"layouts/page/home.html.html",
"demoTheme/layouts/page/home.html.html",
"layouts/page/list.html.html",
"demoTheme/layouts/page/list.html.html",
"layouts/page/index.html",
"demoTheme/layouts/page/index.html",
"layouts/page/home.html",
"demoTheme/layouts/page/home.html",
"layouts/page/list.html",
"demoTheme/layouts/page/list.html",
"layouts/index.html.html",
"demoTheme/layouts/index.html.html",
"layouts/home.html.html",
@ -425,18 +399,6 @@
"OutputFormat": "AMP",
"Suffix": "html",
"Template Lookup Order": [
"layouts/page/index.fr.amp.html",
"layouts/page/home.fr.amp.html",
"layouts/page/list.fr.amp.html",
"layouts/page/index.amp.html",
"layouts/page/home.amp.html",
"layouts/page/list.amp.html",
"layouts/page/index.fr.html",
"layouts/page/home.fr.html",
"layouts/page/list.fr.html",
"layouts/page/index.html",
"layouts/page/home.html",
"layouts/page/list.html",
"layouts/index.fr.amp.html",
"layouts/home.fr.amp.html",
"layouts/list.fr.amp.html",
@ -469,12 +431,6 @@
"OutputFormat": "JSON",
"Suffix": "json",
"Template Lookup Order": [
"layouts/page/index.json.json",
"layouts/page/home.json.json",
"layouts/page/list.json.json",
"layouts/page/index.json",
"layouts/page/home.json",
"layouts/page/list.json",
"layouts/index.json.json",
"layouts/home.json.json",
"layouts/list.json.json",
@ -490,31 +446,136 @@
]
},
{
"Example": "RSS home",
"Example": "RSS home with theme",
"Kind": "home",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
"layouts/page/index.rss.xml",
"layouts/page/home.rss.xml",
"layouts/page/rss.xml",
"layouts/page/list.rss.xml",
"layouts/page/index.xml",
"layouts/page/home.xml",
"layouts/page/list.xml",
"layouts/index.rss.xml",
"demoTheme/layouts/index.rss.xml",
"layouts/home.rss.xml",
"demoTheme/layouts/home.rss.xml",
"layouts/rss.xml",
"demoTheme/layouts/rss.xml",
"layouts/list.rss.xml",
"demoTheme/layouts/list.rss.xml",
"layouts/index.xml",
"demoTheme/layouts/index.xml",
"layouts/home.xml",
"demoTheme/layouts/home.xml",
"layouts/list.xml",
"demoTheme/layouts/list.xml",
"layouts/_default/index.rss.xml",
"demoTheme/layouts/_default/index.rss.xml",
"layouts/_default/home.rss.xml",
"demoTheme/layouts/_default/home.rss.xml",
"layouts/_default/rss.xml",
"demoTheme/layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
"demoTheme/layouts/_default/list.rss.xml",
"layouts/_default/index.xml",
"demoTheme/layouts/_default/index.xml",
"layouts/_default/home.xml",
"demoTheme/layouts/_default/home.xml",
"layouts/_default/list.xml",
"demoTheme/layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
},
{
"Example": "RSS section posts",
"Kind": "section",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
"layouts/posts/section.rss.xml",
"layouts/posts/rss.xml",
"layouts/posts/list.rss.xml",
"layouts/posts/section.xml",
"layouts/posts/list.xml",
"layouts/section/section.rss.xml",
"layouts/section/rss.xml",
"layouts/section/list.rss.xml",
"layouts/section/section.xml",
"layouts/section/list.xml",
"layouts/_default/section.rss.xml",
"layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
"layouts/_default/index.xml",
"layouts/_default/home.xml",
"layouts/_default/section.xml",
"layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
},
{
"Example": "Taxonomy list in categories",
"Kind": "taxonomy",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
"layouts/categories/category.rss.xml",
"layouts/categories/taxonomy.rss.xml",
"layouts/categories/rss.xml",
"layouts/categories/list.rss.xml",
"layouts/categories/category.xml",
"layouts/categories/taxonomy.xml",
"layouts/categories/list.xml",
"layouts/taxonomy/category.rss.xml",
"layouts/taxonomy/taxonomy.rss.xml",
"layouts/taxonomy/rss.xml",
"layouts/taxonomy/list.rss.xml",
"layouts/taxonomy/category.xml",
"layouts/taxonomy/taxonomy.xml",
"layouts/taxonomy/list.xml",
"layouts/category/category.rss.xml",
"layouts/category/taxonomy.rss.xml",
"layouts/category/rss.xml",
"layouts/category/list.rss.xml",
"layouts/category/category.xml",
"layouts/category/taxonomy.xml",
"layouts/category/list.xml",
"layouts/_default/category.rss.xml",
"layouts/_default/taxonomy.rss.xml",
"layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
"layouts/_default/category.xml",
"layouts/_default/taxonomy.xml",
"layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
},
{
"Example": "Taxonomy terms in categories",
"Kind": "taxonomyTerm",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
"layouts/categories/category.terms.rss.xml",
"layouts/categories/terms.rss.xml",
"layouts/categories/rss.xml",
"layouts/categories/list.rss.xml",
"layouts/categories/category.terms.xml",
"layouts/categories/terms.xml",
"layouts/categories/list.xml",
"layouts/taxonomy/category.terms.rss.xml",
"layouts/taxonomy/terms.rss.xml",
"layouts/taxonomy/rss.xml",
"layouts/taxonomy/list.rss.xml",
"layouts/taxonomy/category.terms.xml",
"layouts/taxonomy/terms.xml",
"layouts/taxonomy/list.xml",
"layouts/category/category.terms.rss.xml",
"layouts/category/terms.rss.xml",
"layouts/category/rss.xml",
"layouts/category/list.rss.xml",
"layouts/category/category.terms.xml",
"layouts/category/terms.xml",
"layouts/category/list.xml",
"layouts/_default/category.terms.rss.xml",
"layouts/_default/terms.rss.xml",
"layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
"layouts/_default/category.terms.xml",
"layouts/_default/terms.xml",
"layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
@ -787,7 +848,12 @@
"Aliases": [
"ge"
],
"Examples": []
"Examples": [
[
"{{ if ge .Hugo.Version \"0.36\" }}Reasonable new Hugo version!{{ end }}",
"Reasonable new Hugo version!"
]
]
},
"Gt": {
"Description": "Gt returns the boolean truth of arg1 \u003e arg2.",
@ -2238,6 +2304,20 @@
"Hello world, gophers!"
]
]
},
"Remarshal": {
"Description": "Remarshal is used in the Hugo documentation to convert configuration\nexamples from YAML to JSON, TOML (and possibly the other way around).\nThe is primarily a helper for the Hugo docs site.\nIt is not a general purpose YAML to TOML converter etc., and may\nchange without notice if it serves a purpose in the docs.\nFormat is one of json, yaml or toml.",
"Args": [
"format",
"data"
],
"Aliases": null,
"Examples": [
[
"{{ \"title = \\\"Hello World\\\"\" | transform.Remarshal \"json\" | safeHTML }}",
"{\n \"title\": \"Hello World\"\n}\n"
]
]
}
},
"urls": {