From e45b640f71fb6b2b8ea1cf61d455396e985266d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 9 Mar 2018 13:31:48 +0100 Subject: [PATCH] More layout lookup work Closes #400 --- content/templates/lists.md | 10 +- content/templates/rss.md | 30 ++---- data/docs.json | 190 ++++++++++++++++++++++++++----------- 3 files changed, 142 insertions(+), 88 deletions(-) diff --git a/content/templates/lists.md b/content/templates/lists.md index 85de5fe09..a7462317f 100644 --- a/content/templates/lists.md +++ b/content/templates/lists.md @@ -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//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//layouts/_default/taxonomy.html` +See [Template Lookup Order](/templates/lookup-order/) for the complete reference. ## Add Content and Front Matter to List Pages diff --git a/content/templates/rss.md b/content/templates/rss.md index 4e69185ff..42d6ef62f 100644 --- a/content/templates/rss.md +++ b/content/templates/rss.md @@ -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 [section’s][section] RSS will be rendered at `/
/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/
.rss.xml` -2. `/layouts/_default/rss.xml` -3. `/themes//layouts/section/
.rss.xml` -4. `/themes//layouts/_default/rss.xml` -5. Embedded rss.xml - -### Taxonomy RSS - -1. `/layouts/taxonomy/.rss.xml` -2. `/layouts/_default/rss.xml` -3. `/themes//layouts/taxonomy/.rss.xml` -4. `/themes//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 site’s 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 {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} diff --git a/data/docs.json b/data/docs.json index 7b9a85d31..641d32818 100644 --- a/data/docs.json +++ b/data/docs.json @@ -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": {