Add first drafts of lists, sections, taxonomy templates

This commit is contained in:
Ryan Watters
2017-02-22 21:41:31 -06:00
parent 48fecc4265
commit 742771870a
26 changed files with 542 additions and 524 deletions
+146 -288
View File
@@ -9,7 +9,28 @@
## Changes to Existing Sections
The following is an *abbreviated* listing and only includes the *larger* changes to content organization. These changes do not include copy edits for consistent usage, which easily numbers in the thousands at this point.
The following is an *abbreviated* listing and only includes the *larger* changes to content organization. Everything is ordered according to [existing site structure and site navigation](http://gohugo.io/overview/introduction/). These changes do not include copy edits for consistent usage, which easily numbers in the thousands, if not more.
### Download Hugo
This is no longer a site navigation link and is instead a button along with "File and Issue" and "Discuss Hugo".
### Site Showcase
### Press & Articles
### About Hugo
### Getting Started
### Content
### Themes
### Templates
### Taxonomies
### [Extras](http://gohugo.io/extras)
@@ -19,6 +40,8 @@ The following is an *abbreviated* listing and only includes the *larger* changes
* **Aliases** Incorporated into `/content-management/url-management/`
* **Analytics** Incorporated into /templates/partial-templates/#built-in
### Community
### [Tutorials](http://gohugo.io/tutorials)
* Moved all installation guides to /getting-started/install-hugo/
@@ -27,298 +50,133 @@ The following is an *abbreviated* listing and only includes the *larger* changes
* All content moved from `/tutorials` edited to reflect a less tutorial-ish style of language (e.g., remove of lines starting with "In this tutorial...")
* Aliases added to new pages and in-page links updated throughout
### Troubleshooting
### Tools
### Hugo Cmd Reference
This hasn't been touched. I'll make the necessary style changes once/if the site is integrated into the Hugo GH repo since these pages are pulled automatically using Viper.
### Issues & Help
This is no longer a site navigation link and is instead a button along with "Download" and "Discuss Hugo".
## Content Organization: Site Navigation
The following is a list of weights for the newly restructure site architecture
The following shows weights and ordering for the newly restructured site architecture.
### "About Hugo" Ordering (- weight)
_index - 01
what is hugo - 10
hugo features - 20
the benefits of static - 30
why i built hugo - 40
roadmap - 50
apache license - 60
### "Getting Started" Ordering (- weight)
* _index.md - 01
* quick start - 10
* using the hugo docs - 20
* install from source - 30
* install on linux - 40
* install on mac - 50
* install on pc - 60
* basic usage - 70
* directory structure - 80
* configuration - 90
### "Content Management" Ordering (- weight)
* _index.md - 01
* Content Organization - 10
* Supported Content Formats - 20
* Front Matter - 30
* Shortcodes - 40
* Sections - 50
* Content Types - 60
* Archetypes - 70
* Taxonomies - 80
* Content Summaries - 90
* Cross References - 100
* URL Management - 110
* Menus - 120
* Table of Contents - 130
* Comments - 140
* Multilingual Mode - 150
### "Templates" Ordering (- weight)
* _index - 01
* go template primer - 10
* base templates and blocks - 20
* lists in Hugo - 25
* homepage template - 30
* section templates - 40
* taxonomy templates - 50
* single page templates - 60
* content view templates - 70
* data templates - 80
* partial templates - 90
* shortcode templates - 100
* local file templates - 110
* custom 404 page - 120
* menu templates - 130
* pagination - 140
* rss templates - 150
* sitemap template - 160
* additional templating languages - 170
* template debugging - 180
## "Functions" Ordering
**Ordered by title (note that `.Title` is all lowercase, whereas `.Linktitle` is used for proper casing)**
### "Variables and Params" Ordering (- weight)
* _index.md - 01
* site variables - 10
* page variables - 20
* taxonomy variables - 30
* file variables - 40
* shortcode git and huge variables - 50
### "Hosting and Deployment" Ordering (- weight)
* _index.md - 01
* deployment with rsync - 10
* deployment with wercker - 20
* hosting on bitbucket - 30
* hosting on github - 40
* hosting on gitlab - 50
### "Themes" Ordering (- weight)
* _index.md - 01
* installing and using themes - 10
* customizing a theme - 20
* creating a them - 30
* theme showcase - 30
### "Site Showcase" Ordering
**Ordered by `.PublishDate`**
### "Themes" Ordering (- weight)
* _index.md - 01
* Installing and Using Themes - 10
* Customizing a Theme - 20
* Creating a Theme - 30
* Theme Showcase - 40
### "Troubleshooting" Ordering
**Ordered by title**
## Content Organization: Source
**Updated 2017-02-21**
```
.
├── _index.md
├── about-hugo
│   ├── _index.md
│   ├── benefits-of-static.md
│   ├── hugo-features.md
│   ├── license.md
│   ├── roadmap.md
│   ├── what-is-hugo.md
│   └── why-i-built-hugo.md
├── commands
│   └── _index.md
├── content-management
│   ├── _index.md
│   ├── archetypes.md
│   ├── content-organization.md
│   ├── content-sections.md
│   ├── content-summaries.md
│   ├── content-types.md
│   ├── cross-references.md
│   ├── front-matter.md
│   ├── menus.md
│   ├── multilingual-mode.md
│   ├── shortcodes.md
│   ├── supported-content-formats.md
│   ├── table-of-contents.md
│   ├── taxonomies.md
│   └── url-management.md
├── contribute-to-hugo
│   ├── _index.md
│   ├── add-your-site-to-the-showcase.md
│   ├── contribute-to-hugo-development.md
│   └── contribute-to-the-hugo-docs.md
├── developer-tools
│   ├── _index.md
│   ├── migrate-to-hugo.md
│   └── syntax-highlighting.md
├── functions
│   ├── _index.md
│   ├── abslangurl.md
│   ├── absurl.md
│   ├── after.md
│   ├── apply.md
│   ├── base64decode.md
│   ├── base64encode.md
│   ├── chomp.md
│   ├── countrunes.md
│   ├── countwords.md
│   ├── dateformat.md
│   ├── default-function.md
│   ├── delimit.md
│   ├── dict.md
│   ├── echoparam.md
│   ├── emojify.md
│   ├── findre.md
│   ├── first.md
│   ├── get.md
│   ├── getenv.md
│   ├── getpage.md
│   ├── haschildren.md
│   ├── hasmenucurrent.md
│   ├── hasprefix.md
│   ├── highlight.md
│   ├── htmlescape.md
│   ├── htmlunescape.md
│   ├── humanize.md
│   ├── i18n.md
│   ├── imageconfig.md
│   ├── in.md
│   ├── index-function.md
│   ├── int.md
│   ├── intersect.md
│   ├── ismenucurrent.md
│   ├── isset.md
│   ├── jsonify.md
│   ├── last.md
│   ├── lower.md
│   ├── markdownify.md
│   ├── math.md
│   ├── md5.md
│   ├── param.md
│   ├── partialcached.md
│   ├── plainify.md
│   ├── pluralize.md
│   ├── printf.md
│   ├── querify.md
│   ├── range.md
│   ├── readdir.md
│   ├── readfile.md
│   ├── rel.md
│   ├── rellangurl.md
│   ├── relref.md
│   ├── relurl.md
│   ├── render.md
│   ├── replace.md
│   ├── safecss.md
│   ├── safehtml.md
│   ├── safehtmlattr.md
│   ├── safejs.md
│   ├── safeurl.md
│   ├── scratch.md
│   ├── seq.md
│   ├── sha1.md
│   ├── sha256.md
│   ├── shuffle.md
│   ├── singularize.md
│   ├── slice.md
│   ├── slicestr.md
│   ├── sort.md
│   ├── split.md
│   ├── string.md
│   ├── substr.md
│   ├── the-dot.md
│   ├── time.md
│   ├── title.md
│   ├── trim.md
│   ├── unix.md
│   ├── upper.md
│   ├── urlize.md
│   ├── where.md
│   └── with.md
├── getting-started
│   ├── _index.md
│   ├── basic-usage.md
│   ├── configuration.md
│   ├── directory-structure.md
│   ├── install-hugo.md
│   ├── quick-start.md
│   └── using-the-hugo-docs.md
├── hosting-and-deployment
│   ├── _index.md
│   ├── deployment-with-rsync.md
│   ├── deployment-with-wercker.md
│   ├── hosting-on-bitbucket.md
│   ├── hosting-on-github.md
│   └── hosting-on-gitlab.md
├── mailing-list.md
├── news
│   ├── _index.md
│   ├── press-and-articles.md
│   └── release-notes.md
├── showcase
│   ├── 2626info.md
│   ├── _index.md
│   ├── antzucaro.md
│   ├── appernetic.md
│   ├── arresteddevops.md
│   ├── asc.md
│   ├── astrochili.md
│   ├── aydoscom.md
│   ├── barricade.md
│   ├── bepsays.md
│   ├── bugtrackers.io.md
│   ├── camunda-blog.md
│   ├── camunda-docs.md
│   ├── cdnoverview.md
│   ├── chinese-grammar.md
│   ├── chingli.md
│   ├── chipsncookies.md
│   ├── christianmendoza.md
│   ├── cinegyopen.md
│   ├── clearhaus.md
│   ├── cloudshark.md
│   ├── coding-journal.md
│   ├── consequently.md
│   ├── ctlcompiled.md
│   ├── danmux.md
│   ├── datapipelinearchitect.md
│   ├── davidepetilli.md
│   ├── davidrallen.md
│   ├── davidyates.md
│   ├── devmonk.md
│   ├── dmitriid.com.md
│   ├── emilyhorsman.com.md
│   ├── esolia-com.md
│   ├── esolia-pro.md
│   ├── eurie.md
│   ├── fale.md
│   ├── fixatom.md
│   ├── fxsitecompat.md
│   ├── gntech.md
│   ├── gogb.md
│   ├── goin5minutes.md
│   ├── h10n.me.md
│   ├── hugo.md
│   ├── jamescampbell.md
│   ├── jorgennilsson.md
│   ├── kieranhealy.md
│   ├── klingt-net.md
│   ├── launchcode5.md
│   ├── leepenney.md
│   ├── leowkahman.md
│   ├── lk4d4.darth.io.md
│   ├── losslesslife.md
│   ├── mariosanchez.md
│   ├── mayan-edms.md
│   ├── michaelwhatcott.md
│   ├── mongodb-eng-journal.md
│   ├── mtbhomer.md
│   ├── nickoneill.md
│   ├── ninjaducks.in.md
│   ├── ninya.io.md
│   ├── nodesk.md
│   ├── novelist-xyz.md
│   ├── npf.md
│   ├── peteraba.md
│   ├── rahulrai.md
│   ├── rakutentech.md
│   ├── rdegges.md
│   ├── readtext.md
│   ├── richardsumilang.md
│   ├── rick-cogley-info.md
│   ├── ridingbytes.md
│   ├── robertbasic.md
│   ├── scottcwilson.md
│   ├── shapeshed.md
│   ├── shelan.md
│   ├── silvergeko.md
│   ├── softinio.md
│   ├── spf13.md
│   ├── steambap.md
│   ├── stefano.chiodino.md
│   ├── stou.md
│   ├── szymonkatra.md
│   ├── techmadeplain.md
│   ├── tendermint.md
│   ├── thecodeking.md
│   ├── thehome.md
│   ├── tutorialonfly.md
│   ├── ucsb.md
│   ├── upbeat.md
│   ├── vamp.md
│   ├── viglug.org.md
│   ├── vurt.co.md
│   ├── yslow-rules.md
│   ├── ysqi.md
│   └── yulinling.net.md
├── templates
│   ├── _index.md
│   ├── ace-templating.md
│   ├── amber-templating.md
│   ├── base-templates-and-blocks.md
│   ├── content-view-templates.md
│   ├── custom-404-page.md
│   ├── data-templates.md
│   ├── go-template-primer.md
│   ├── homepage-template.md
│   ├── section-and-listtemplates.md
│   ├── local-file-templates.md
│   ├── menu-templates.md
│   ├── pagination.md
│   ├── partial-templates.md
│   ├── rss-templates.md
│   ├── shortcode-templates.md
│   ├── single-page-templates.md
│   ├── sitemap-template.md
│   ├── taxonomy-templates.md
│   └── template-debugging.md
├── themes
│   ├── _index.md
│   ├── creating-a-theme.md
│   ├── customizing-a-theme.md
│   ├── installing-and-using-themes.md
│   └── theme-showcase.md
├── troubleshooting
│   ├── _index.md
│   ├── accented-characters-in-urls.md
│   └── eof-error.md
├── tutorials
│   ├── _index.md
│   ├── create-a-multilingual-site.md
│   ├── creating-a-new-theme.md
│   └── migrate-from-jekyll-to-hugo.md
└── variables-and-params
├── _index.md
├── file-variables.md
├── page-variables.md
├── shortcode-git-and-hugo-variables.md
├── site-variables.md
└── taxonomy-variables.md
15 directories, 264 files
```
**[See tree.md at the root of this repository](tree.md).**
@@ -48,7 +48,7 @@ Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> exactly
## Example: First 10 Articles with Summaries
You can show content summaries with the following code. You could use the following snipper, for example, in a [section's list page template][].
You can show content summaries with the following code. You could use the following snipper, for example, in a [section template][].
{{% input "page-list-with-summaries.html" %}}
```html
@@ -72,4 +72,4 @@ Note how the `.Truncated` boolean valuable may be used to hide the "Read More...
[org]: /content-management/supported-content-formats/
[pagevariables]: /variables-and-params/page-variables/
[section's list page template]: /templates/section-and-list-templates/
[section template]: /templates/section-templates/
+2 -2
View File
@@ -50,7 +50,7 @@ Create a file called `post.html` inside the section lists template directory, `/
### Create views
Many sites support rendering content in a few different ways, for instance, a single page view and a summary view to be used when displaying a [list of contents on a single page][]. Hugo makes no assumptions about how you want to display your content and will support as many different views of a content type as your site requires. All that is required for these additional views is that a template exists in each `/layouts/TYPE` directory with the same name.
Many sites support rendering content in a few different ways, for instance, a single page view and a summary view to be used when displaying a [list of section contents][]. Hugo makes no assumptions about how you want to display your content and will support as many different views of a content type as your site requires. All that is required for these additional views is that a template exists in each `/layouts/TYPE` directory with the same name.
### Create A Corresponding Archetype
@@ -62,6 +62,6 @@ More details about archetypes can be found in the [archetypes documentation][].
[archetypes documentation]: /content-management/archetypes/
[sections]: /content-management/sections/
[front matter]: /content-management/front-matter/
[list of contents on a single page]: /templates/section-and-list-templates/
[list of section contents]: /templates/section-templates/
[template]: /templates/
[Tumblr]: https://www.tumblr.com/
+2 -2
View File
@@ -49,7 +49,7 @@ Hugo will automatically create pages for each section root that list all of the
As of Hugo v0.18, section pages can also have a content file and front matter. These section content files must be placed in their corresponding section folder and named `_index.md` in order for Hugo to correctly render the front matter and content.
{{% warning "`index.md` vs `_index.md`" %}}
Hugo themes developed before v0.18 often used an `index.md` in a content section as a hack to emulate the behavior of `_index.md`. The hack may work...*sometimes*; however, the order of page rendering can be unpredictable in Hugo. What works now may fail to render appropriately as your site grows. It is **strongly advised** to use `_index.md` as the *preferred* content section index page. **Note:** `_index.md`'s layout, as representative of a section, is a [list template](/templates/section-and-list-templates/) and *not* a [single template](/templates/single-page-templates/).
Hugo themes developed before v0.18 often used an `index.md` in a content section as a hack to emulate the behavior of `_index.md`. The hack may work...*sometimes*; however, the order of page rendering can be unpredictable in Hugo. What works now may fail to render appropriately as your site grows. It is **strongly advised** to use `_index.md` as the *preferred* content section index page. **Note:** `_index.md`'s layout, as representative of a section, is a [list template](/templates/section-templates/) and *not* a [single template](/templates/single-page-templates/).
{{% /warning %}}
## Content *Section* vs Content *Type*
@@ -60,6 +60,6 @@ By default, everything created within a section will use the [content type][] th
[content type]: /content-management/content-types/
[example site]: /getting-started/using-the-hugo-docs/
[directory structure]: /getting-started/directory-structure/
[listsandsectiontemplatespage]: /templates/section-and-list-templates/
[listsandsectiontemplatespage]: /templates/section-templates/
+13 -4
View File
@@ -11,7 +11,6 @@ weight: 80
draft: false
aliases: [/taxonomies/overview/,/taxonomies/usage/,/indexes/overview/,/doc/indexes/,/extras/indexes]
toc: true
notesforauthors:
---
## What is a Taxonomy?
@@ -124,13 +123,23 @@ taxonomies:
### Overriding Hugo's Default Taxonomies
If you do not specify any taxonomies in your [site configuration][] file ***and*** your content already includes front matter with `tags:` or `categories`, Hugo will automatically create taxonomy pages. To override this behavior, set the key-value pairs for both of the default taxonomies to empty strings in your `config` file.
If you do not specify any taxonomies in your [site configuration][] file *and* your content already includes front matter with `tags:` or `categories`, Hugo will automatically create taxonomy pages. To override this behavior, set the key-value pairs for both of the default taxonomies to empty strings in your `config` file.
{{% input "remove-default-taxonomies-config.toml" %}}
```toml
[taxonomies]
tag = ""
category = ""
```
{{% /input %}}
{{% input "remove-default-taxonomies-config.yml" %}}
```yaml
taxonomies:
tag: ""
category: ""
```
{{% /input %}}
### Preserving Taxonomy Values
@@ -200,7 +209,7 @@ project_url: "https://github.com/spf13/hugo"
## Adding Taxonomic `weight` to Content
A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates][] and is declared in the content file's [front matter][]. The convention for declaring taxonomic weight is `taxonomyname_weight`.
A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates][] and is declared in a content file's [front matter][]. The convention for declaring taxonomic weight is `taxonomyname_weight`.
The following TOML and YAML examples show a piece of content that has a weight of 22, which can be used for ordering purposes when rendering the pages assigned to the "a", "b" and "c" values of the `tags` taxonomy. It has also been assigned the weight of 44 when rendering the "d" category page.
@@ -244,5 +253,5 @@ Currently taxonomies only support the default ordering of content which is weigh
[site configuration]: /project-organization/configuration/
[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-page-templates
[taxonomy templates]: /templates/taxonomy-templates/
[taxonomy terms templates]: /templates/taxonomy-templates/#taxonomy-terms-templates "See how to order terms associated with taxonomy via taxonomy templates"
[taxonomy terms templates]: /templates/taxonomy-templates/#taxonomy-terms-templates "See how to order terms associated with a taxonomy"
[website configuration]: /project-organization/configuration/
@@ -17,31 +17,31 @@ needsreview: true
Documentation is an integral part of any open source project. The Hugo docs were completely reworked in anticipation of the release of v0.19, but there is always room for improvement.
## Edit Locally and Submit a Pull Request
<!-- ## Edit Locally and Submit a Pull Request
**IN DEVELOPMENT**
## How Content is Ordered in the Hugo Docs
**IN DEVELOPMENT**
**IN DEVELOPMENT** -->
## Creating New Files from Archetypes
## Creating New Content for the Hugo Docs
**IN DEVELOPMENT**
### New Default Content
### Creating Default Content
**IN DEVELOPMENT**
### New Function
### Adding a New Function
**IN DEVELOPMENT**
### New Showcase
### Adding a New Showcase
**IN DEVELOPMENT**
### New Tutorial
### Adding a New Tutorial
**IN DEVELOPMENT**
@@ -57,10 +57,6 @@ Documentation is an integral part of any open source project. The Hugo docs were
**IN DEVELOPMENT**
### Example Site Code Block
**IN DEVELOPMENT**
## Blockquotes
@@ -82,9 +78,9 @@ Previous versions of the Hugo documentation used [Markdown `<blockquote>` syntax
Use the `note` shortcode when you want to draw attention to information subtly. `note` is intended to be less of an interruption in content than is `warning`.
#### Example `note` Admonition Shortcode Input
#### `note` Admonition Shortcode Input
{{% input "example-note-with-heading.md" %}}
{{% input "note-with-heading.md" %}}
```golang
{{%/* note "Example Note Admonition" */%}}
Here is a piece of information I would like to draw your **attention** to.
@@ -92,30 +88,50 @@ Here is a piece of information I would like to draw your **attention** to.
```
{{% /input %}}
#### Examle `note` Admonition Shortcode Output
#### `note` Admonition Shortcode Output (Code)
{{% output "note-with-heading.html" %}}
```html
{{% note "Example Note Admonition" %}}
Here is a piece of information I would like to draw your **attention** to.
{{% /note %}}
```
{{% /output %}}
#### `note` Admonition Shortcode Display
{{% note "Example Note Admonition" %}}
Here is a piece of information I would like to draw your **attention** to.
{{% /note %}}
### Warning Admonition Shortcode
### Warning Admonition Examples
Use the `warning` shortcode when you want to draw the user's attention
Use the `warning` shortcode when you want to draw the user's attention to something important. A good usage example is for announcing breaking changes for Hugo versions, known bugs, or templating gotchas.
#### Example `warning` Admonition Shortcode Input
#### `warning` Admonition Shortcode Input
{{% input "example-note.md" %}}
{{% input "warning-admonition-input.md" %}}
```golang
{{%/* warning "Example Warning" */%}}
This is a warning, which should be reserved for *important* information like breaking changes, bad practices, etc.
This is a warning, which should be reserved for *important* information like breaking changes.
{{%/* /warning */%}}
```
{{% /input %}}
#### Example `warning` Admonition Shortcode Output
#### `warning` Admonition Shortcode Output
{{% output "warning-admonition-output.html" %}}
```html
{{% warning "Example Warning" %}}
This is a warning, which should be reserved for *important* information like breaking changes.
{{% /warning %}}
```
{{% /output %}}
#### `warning` Admonition Shortcode Display
{{% warning "Example Warning" %}}
This is a warning, which should be reserved for *important* information like breaking changes, bad practices, etc.
This is a warning, which should be reserved for *important* information like breaking changes.
{{% /warning %}}
## Example Site Shortcodes
+17
View File
@@ -0,0 +1,17 @@
---
title: count
linktitle: Count
description:
godocref:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
tags: []
categories: [functions]
toc: false
draft: false
aliases: []
notesforauthors:
---
[Link to Taxonomy templates](/templates/taxonomy-templates/)
+1 -1
View File
@@ -594,7 +594,7 @@ git push
[frontmatter]: /content-management/front-matter/
[hugodirectories]: /getting-started/directory-structure/
[installhugo]: /getting-started/install-hugo/
[listsectiontemplates]: /templates/section-and-list-templates/
[listsectiontemplates]: /templates/section-templates/
[partialtemplates]: /templates/partial-templates/
[quickinstall]: /getting-started/install-hugo/#quick-install
[releases]: https://github.com/spf13/hugo/releases
+28
View File
@@ -0,0 +1,28 @@
---
title: Lists in Hugo
linktitle: Lists in Hugo
description:
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [templates]
tags: [lists,sections,rss,taxonomies,terms]
weight: 25
draft: false
aliases: [/templates/list/]
toc: true
needsreview: true
---
## What is a "List" Template
A list page template is a template used to render multiple pieces of content in a single HTML page (with the exception of the [homepage][] which has a dedicated template). The idea of a list page comes from the [hierarchical mental model of the web][mentalmodel] and is best demonstrated visually:
![Image demonstrating a hierarchical website sitemap.](/images/)
We are using the term *list* in its truest sense: a sequential arrangement of material, especially in alphabetical or numerical order. Hugo uses list templates to render any place where content is being listed (e.g., taxonomies and sections).
[homepage]: /templates/homepage-template/
[mentalmodel]: http://webstyleguide.com/wsg3/3-information-architecture/3-site-structure.html
+20 -1
View File
@@ -18,10 +18,28 @@ needsreview: true
Like all other templates, you can use a single RSS template to generate all of your RSS feeds, or you can create a specific template for each individual feed.
* /layouts/section/`SECTION`.rss.xml
* /layouts/\_default/rss.xml
* /themes/`THEME`/layouts/section/`SECTION`.rss.xml
* /themes/`THEME`/layouts/\_default/rss.xml
{{% note "Hugo Ships with an RSS Template" %}}
*Unlike other Hugo templates*, Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320). In most cases this will be sufficient, and an RSS template will not need to be provided by the user. But you can provide an rss template if you like, as you can see in the next section.
{{% /note %}}
RSS pages are of the type `Page` and have all the [page variables](/layout/variables/) available to use in the templates.
### Section RSS
A [sections][section] RSS will be rendered at /`SECTION`/index.xml (e.g., http://spf13.com/project/index.xml)
*Hugo ships with its own [RSS 2.0][] template. In most cases this will
be sufficient, and an RSS template will not need to be provided by the
user.*
Hugo provides the ability for you to define any RSS type you wish, and
can have different RSS files for each section and taxonomy.
## Which Template will be Rendered?
Hugo uses a set of rules to figure out which template to use when rendering a specific page.
@@ -121,4 +139,5 @@ The `.RSSLink` will render the appropriate RSS feed URL for the section, whether
<a href="{{ .URL }}" type="application/rss+xml" target="_blank">{{ .SomeText }}</a>
```
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
[section]: /content-management/sections/
@@ -1,6 +1,6 @@
---
title: Section and List Page Templates
linktitle: Section and List Page Templates
title: Section Page Templates
linktitle: Section Page Templates
description:
date: 2017-02-01
publishdate: 2017-02-01
@@ -9,27 +9,22 @@ categories: [templates]
tags: [lists,sections]
weight: 40
draft: false
aliases: [/templates/list/]
aliases: []
toc: true
needsreview: true
---
A list template is any template that will be used to render multiple pieces of
content in a single HTML page (with the exception of the [homepage](/layout/homepage/) which has a
dedicated template).
## Introduction to the Template Lookup Order
We are using the term *list* in its truest sense, a sequential arrangement of material, especially in alphabetical or numerical order. Hugo uses list templates to render anyplace where content is being listed such as taxonomies and sections.
{{< lookupexplanation >}}
## Lookup Order for List and Section Page Templates
Hugo uses a set of rules to figure out which template to use when
rendering a specific page.
Hugo will use the following prioritized list. If a file isnt present,
then the next one in the list will be used. This enables you to craft
specific layouts when you want to without creating more templates
than necessary. For most sites only the \_default file at the end of
the list will be needed.
## Lookup Order for Section Page Templates
Hugo uses a set of rules to figure out which template to use when rendering a specific page.
Hugo will use the following prioritized list. If a file isnt present, then the next one in the list will be used. This enables you to craft specific layouts when you want to without creating more templates than necessary. For most sites only the \_default file at the end of the list will be needed.
### Section Lists
@@ -57,22 +52,6 @@ A Taxonomy will be rendered at /`PLURAL`/`TERM`/ (e.g.&nbsp;http://spf13.com/top
Note that a taxonomy list page can also have a content file with frontmatter, see [Source Organization](/overview/source-directory/).
### Section RSS
A Sections RSS will be rendered at /`SECTION`/index.xml (e.g.&nbsp;http://spf13.com/project/index.xml)
*Hugo ships with its own [RSS 2.0][] template. In most cases this will
be sufficient, and an RSS template will not need to be provided by the
user.*
Hugo provides the ability for you to define any RSS type you wish, and
can have different RSS files for each section and taxonomy.
* /layouts/section/`SECTION`.rss.xml
* /layouts/\_default/rss.xml
* /themes/`THEME`/layouts/section/`SECTION`.rss.xml
* /themes/`THEME`/layouts/\_default/rss.xml
### Taxonomy RSS
A Taxonomys RSS will be rendered at /`PLURAL`/`TERM`/index.xml (e.g.&nbsp;http://spf13.com/topics/golang/index.xml)
@@ -101,27 +80,31 @@ Taxonomy pages will additionally have:
## Example List Template Pages
### Example section template (post.html)
### Example Section Template: `post.html`
This content template is used for [spf13.com](http://spf13.com/).
It makes use of [partial templates](/templates/partials/). All examples use a
It makes use of [partial templates][partials]. All examples use a
[view](/templates/views/) called either "li" or "summary" which this example site
defined.
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
{{% input "layouts/section/post.html" %}}
```html
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
<ul id="list">
{{ range .Data.Pages }}
{{ .Render "li"}}
{{ end }}
</ul>
</div>
</section>
{{ partial "footer.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
<ul id="list">
{{ range .Data.Pages }}
{{ .Render "li"}}
{{ end }}
</ul>
</div>
</section>
{{ partial "footer.html" . }}
```
{{% /input %}}
### Example taxonomy template (tag.html)
This content template is used for [spf13.com](http://spf13.com/).
@@ -394,37 +377,80 @@ you can do just that.
### `first`
`first` works like the `limit` keyword in SQL. It reduces the array to only the
first _N_ elements. It takes the array and number of elements as input.
`first` works in a similar manner to the [`limit` keyword in SQL][limitkeyword]. It reduces the array to only the `first N` elements. It takes the array and number of elements as input. `first` takes two arguments:
{{ range first 10 .Data.Pages }}
{{ .Render "summary" }}
{{ end }}
1. `array` or `slice of maps or structs`
2. `number of elements`
{{% input "layout/_default/section.html" %}}
```golang
{{ range first 10 .Data.Pages }}
{{ .Render "summary" }}
{{ end }}
```
{{% /input %}}
### `where`
`where` works in a similar manner to the `where` keyword in SQL. It selects all
elements of the slice that match the provided field and value. It takes three
arguments: 'array or slice of maps or structs', 'key or field name' and 'match
value'.
`where` works in a similar manner to the `where` keyword in SQL. It selects all elements of the array or slice that match the provided field and value. `where` takes three arguments:
{{ range where .Data.Pages "Section" "post" }}
{{ .Content }}
{{ end }}
1. `array` or a `slice of maps or structs`
2. `key` or `field name'
3. `match value`
### `first` & `where` Together
{{% input "layouts/_default/.html" %}}
```html
{{ range where .Data.Pages "Section" "post" }}
{{ .Content }}
{{ end }}
```
{{% /input %}}
Using both together can be very powerful.
### `first` and `where` Together
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ .Content }}
{{ end }}
Using `first` and `where` together can be very powerful:
If `where` or `first` receives invalid input or a field name that doesnt exist,
it will return an error and stop site generation.
{{% input "first-and-where-together.html" %}}
```golang
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ .Content }}
{{ end }}
```
{{% /input %}}
These are both template functions and work on not only
[lists](/templates/list/), but [taxonomies](/taxonomies/displaying/),
[terms](/templates/terms/) and [groups](/templates/list/).
{{% note %}}
If `where` or `first` receives invalid input or a field name that doesnt exist, it will return an error and stop site generation. `where` and `first` also work on taxonomy list templates *and* taxonomy terms templates. (See [Taxonomy Templates](/templates/taxonomy-templates/).)
{{% /note %}}
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
## `.Site.GetPage`
Every `Page` in Hugo has a `.Kind` attribute. `Kind` can easily be combined with [`where`](/functions/where/) in your templates to create kind-specific lists of content, but there are times where you may want to fetch the index page of a single section by the section's path.
[`.GetPage`](/function/getpage/) looks up an index page (i.e `_index.md`) of a given `Kind` and `path`. This method is only supported in section page templates but *may* support [single page templates][singlepages] in the future.
`.Site.GetPage` takes two arguments: `kind` and `kind value`.
The valid values for 'kind' are as follows:
1. `home`
2. `section`
3. `taxonomy`
4. `taxonomyTerm`
### `.Site.GetPage` Example
The `.Site.GetPage` example assumes the following project directory structure:
{{% input "grab-blog-section-index-page-title.html" %}}
{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}
{{% /input %}}
`.Site.GetPage` will return `nil` if no `_index.md` page is found. If `content/blog/_index.md` does not exist, the template will output a blank section where `{{.Title}}` should have been in the preceding example.
[sections]: /content-management/sections/
[directorystructure]: /getting-started/directory-structure/
[homepage]: /templates/homepage-template/
[limitkeyword]: https://www.techonthenet.com/sql/select_limit.php
[partials]: /templates/partial-templates/
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
[singlepages]: /templates/single-page-templates/
+18 -23
View File
@@ -15,24 +15,16 @@ toc: true
The primary view of content in Hugo is the single view. Hugo will render every Markdown file provided with a corresponding single template.
## Which Template Will be Rendered?
## Introduction to the Template Lookup Order
Hugo uses a set of rules to figure out which template to use when rendering a specific page.
Hugo will use the following prioritized list. This list is an inverted cascade: if a file isnt present, Hugo will look to the next file. If that next file isn't present, Hugo will look to the file after that, and so on until it reaches the `_default` layout directory for the project and then the theme.
The template lookup order enables you to craft specific layouts as needed without creating more templating than necessary. For most sites, only the `_default/*html` files at the end of the list will be needed.
You can specify `type` (i.e., [content type][]) and `layout` in a content file's [front matter][]. However, you cannot specify `section` because this is determined based on file location (i.e. it's content [section][]).
{{% note "Hugo Makes Assumptions" %}}
Hugo assumes your content section and content type are the same unless you tell Hugo otherwise by providing a `type` directly in the front matter of a content file.
{{% /note %}}
This is why #1 and #3 come before #2 and #4, respectively. Values in angle brackets (`<>`) are variables.
{{< lookupexplanation >}}
## Lookup Order for Single Page Templates
You can specify `type` (i.e., [content type][]) and `layout` in a single content file's [front matter][]. However, you cannot specify `section` because this is determined based on file location (see [content section][section]).
Hugo assumes your content section and content type are the same unless you tell Hugo otherwise by providing a `type` directly in the front matter of a content file. This is why #1 and #3 come before #2 and #4, respectively, in the following lookup order. Values in angle brackets (`<>`) are variable.
1. `/layouts/<TYPE>/<LAYOUT>.html`
2. `/layouts/<SECTION>/<LAYOUT>.html`
3. `/layouts/<TYPE>/single.html`
@@ -82,7 +74,7 @@ The following examples assume two things:
Now we can look at the front matter for the three single-page content (i.e.`.md`) files.
{{% note "Three Content Pages but *Four* Markdown Files?" %}}
`_index.md` may seem like a single page of content but is actually a specific `kind` in Hugo. Whereas `my-first-post.md`, `my-second-post.md`, and `my-first-event.md` are all of kind `page`, all `_index.md` files in a Hugo project are of kind `section` and therefore do not submit themselves to the ***single*** page template lookup. Instead, `events/_index.md` will render according to the lookup order of [section and list templates](templates/section-and-list-templates/).
`_index.md` may seem like a single page of content but is actually a specific `kind` in Hugo. Whereas `my-first-post.md`, `my-second-post.md`, and `my-first-event.md` are all of kind `page`, all `_index.md` files in a Hugo project are of kind `section` and therefore do not submit themselves to the *single* page template lookup. Instead, `events/_index.md` will render according to its [section template](templates/section-templates/) and respective lookup order.
{{% /note %}}
### `my-first-post.md`
@@ -111,7 +103,9 @@ When it comes time for Hugo to render the content to the page, it will go throug
9. <span class="na">`/themes/mytheme/layouts/posts/single.html`</span>
10. <span class="na">`/themes/mytheme/layouts/_default/single.html`</span>
Notice the term `UNSPECIFIED` rather than `UNDEFINED`. If you don't tell Hugo the specific type and layout, it makes inferences based on sane defaults. `my-first-post.md` does not specify a content `type` in its front matter. Therefore, Hugo assumes the content `type` and `section` (i.e. `posts`, which is defined by file location) are one in the same. The `layout` also is not specified in the front matter. Hugo assumes that `my-first-post.md`, which is of type `page` and a *single* piece of content, should default to the next occurrence of a `single.html` template in the lookup.
Notice the term `UNSPECIFIED` rather than `UNDEFINED`. If you don't tell Hugo the specific type and layout, it makes assumptions based on sane defaults. `my-first-post.md` does not specify a content `type` in its front matter. Therefore, Hugo assumes the content `type` and `section` (i.e. `posts`, which is defined by file location) are one in the same. ([Read more on sections][section].)
`my-first-post.md` also does not specify a `layout` in its front matter. Therefore, Hugo assumes that `my-first-post.md`, which is of type `page` and a *single* piece of content, should default to the next occurrence of a `single.html` template in the lookup (#4).
### `my-second-post.md`
@@ -127,7 +121,7 @@ layout: reviewarticle
```
{{% /input %}}
Here is the lookup order for `my-second-post.md`:
Here is the way Hugo's traverses the single-page lookup order for `my-second-post.md`:
1. <span class="yes">`/layouts/review/reviewarticle.html`</span>
<br>**BREAK**
@@ -141,7 +135,7 @@ Here is the lookup order for `my-second-post.md`:
9. <span class="na">`/themes/mytheme/layouts/posts/single.html`</span>
10. <span class="na">`/themes/mytheme/layouts/_default/single.html`</span>
In the case of `my-second-post.md`, the front matter specifies the content `type` as well as the `layout`. Hugo finds the layout it needs at the top level of the lookup and does not continue to search through the other templates.
The front matter in `my-second-post.md` specifies the content `type` (i.e. `review`) as well as the `layout` (i.e. `reviewarticle`). Hugo finds the layout it needs at the top level of the lookup (#1) and does not continue to search through the other templates.
{{% note "Type and not Types" %}}
Notice that the directory for the template for `my-second-post.md` is `review` and not `reviews`. This is because *type is always singular*.
@@ -159,7 +153,7 @@ description: This is an upcoming event..
```
{{% /input %}}
Here is the lookup order for `my-first-event.md`:
Here is the way Hugo's traverses the single-page lookup order for `my-first-event.md`:
1. <span class="no">`/layouts/UNSPECIFIED/UNSPECIFIED.html`</span>
2. <span class="no">`/layouts/events/UNSPECIFIED.html`</span>
@@ -177,11 +171,11 @@ Here is the lookup order for `my-first-event.md`:
`my-first-event.md` is significant because it demonstrates the role of the lookup order in Hugo themes. Both the root project directory *and* the `mytheme` themes directory have a file at `_default/single.html`. Understanding this order allows you to [customize Hugo themes](/themes/customizing-a-theme/) by creating template files with identical names in your project directory that step in front of theme template files in the lookup. This allows you to customize the look and feel of your website while maintaining compatibility with the theme's upstream.
{{% /note %}}
## Single Page Template Files Examples
## Example Single Page Templates
Content pages are of the type `page` and will therefore have all the [page variables][] and [site variables][] available to use in their templates.
### Example: `post/single.html`
### `post/single.html`
This content template is used for [spf13.com][spf13]. It makes use of [partial templates][partials]:
@@ -230,7 +224,7 @@ This content template is used for [spf13.com][spf13]. It makes use of [partial t
```
{{% /input %}}
### Example: `project/single.html`
### `project/single.html`
This content template is also used for [spf13.com][spf13] and makes use of [partial templates][partials]:
@@ -286,9 +280,10 @@ To easily generate new instances of this content type (e.g., new `.md` files in
[config]: /getting-started/configuration/
[content type]: /content-management/content-types/
[directory structure]: /getting-started/directory-structure/
[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
[front matter]: /content-management/front-matter/
[page variables]: /variables-and-parms/page-variables/
[partials]: /templates/partial-templates/
[section]: /content-management/content-sections/
[section]: /content-management/sections/
[site variables]: /variables-and-params/site-variables/
[spf13]: http://spf13.com/
+120 -92
View File
@@ -9,17 +9,41 @@ categories: [templates]
tags: [taxonomies,metadata,front matter,terms]
weight: 50
draft: false
aliases: [/taxonomies/displaying/,/indexes/displaying/,/taxonomies/templates/,/indexes/ordering/]
needsreview: true
aliases: [/taxonomies/displaying/,/templates/terms/,/indexes/displaying/,/taxonomies/templates/,/indexes/ordering/]
toc: true
notesforauthors:
needsreview: true
---
<!-- Begin /taxonomies/methods/ -->
Hugo includes support for user-defined groupings of content called **taxonomies**. Taxonomies are classifications that demonstrate logical relationships between content. See [Taxonomies](/content-management/taxonomies) if you are unfamiliar with how Hugo uses taxonomies for content management.
Hugo provides multiple ways to leverage taxonomies through your project:
* Order the way the terms for a taxonomy are displayed in a [taxonomy terms template](#taxonomy-terms-template)
* Order the way content associated with a taxonomy term are display in a [taxonomy list template](#taxonomy-list-template)
* List a single content's taxonomy terms within a [single page template]()
## Introduction to the Template Lookup Order
{{< lookupexplanation >}}
## Taxonomy List Templates
### Lookup Order for Taxonomy List Templates
## Taxonomy Terms Template
### Lookup Order for Taxonomy Terms Templates
{{% note "The Taxonomy Terms Template has a Unique Lookup Order" %}}
Compared to taxonomy list pages and [other list templates](/templates/section-templates/), a terms template lookup has only two options. If Hugo does not find a terms template in `layout/` or `/themes/<yourchosentheme>/layouts/`, Hugo will *not* render a taxonomy terms page.,
{{% /note %}}
<!-- Begin /taxonomies/methods/ -->
Hugo makes a set of values and methods available on the various Taxonomy structures.
## Taxonomy Methods
### Taxonomy Methods
A Taxonomy is a `map[string]WeightedPages`.
@@ -35,7 +59,7 @@ A Taxonomy is a `map[string]WeightedPages`.
.ByCount
: Returns an OrderedTaxonomy (slice) ordered by number of entries.
## OrderedTaxonomy
### OrderedTaxonomy
Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order.
@@ -76,44 +100,43 @@ type WeightedPages []WeightedPage
<!-- Begin /taxonomies/ordering/ -->
Hugo provides the ability to both:
1. Order the way the keys for a taxonomy are displayed
2. Order the way taxonomyed content appears
## Ordering Taxonomies
Taxonomies can be ordered by either alphabetical key or by the number of content pieces assigned to that key.
### Order Alphabetically Example
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.Alphabetical }}
<li><a href="{{ .Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
```
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.Alphabetical }}
<li><a href="{{ .Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
```
### Order by Popularity Example
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.ByCount }}
<li><a href="{{ .Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
```
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.ByCount }}
<li><a href="{{ .Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
```
[See Also Taxonomy Lists](/templates/list/)
<!-- [See Also Taxonomy Lists](/templates/list/) -->
## Ordering Content within Taxonomies
Hugo uses both **Date** and **Weight** to order content within taxonomies.
Hugo uses both `date` and `weight` to order content within taxonomies.
Each piece of content in Hugo can optionally be assigned a date.
It can also be assigned a weight for each taxonomy it is assigned to.
Each piece of content in Hugo can optionally be assigned a date. It can also be assigned a weight for each taxonomy it is assigned to.
When iterating over content within taxonomies the default sort is first by weight then by date. This means that if the weights for two pieces of content are the same, than the more recent content will be displayed first. The default weight for any piece of content is 0.
When iterating over content within taxonomies, the default sort is the same as that used for [section and list pages]() first by weight then by date. This means that if the weights for two pieces of content are the same, than the more recent content will be displayed first. The default weight for any piece of content is 0.
### Assigning Weight
@@ -146,9 +169,7 @@ There are two different templates that the use of taxonomies will require you to
Both templates are covered in detail in the templates section.
A [list template](/templates/list/) is any template that will be used to render multiple pieces of
content in a single html page. This template will be used to generate
all the automatically created taxonomy pages.
A [list template](/templates/list/) is any template that will be used to render multiple pieces of content in a single html page. This template will be used to generate all the automatically created taxonomy pages.
A [taxonomy terms template](/templates/terms/) is a template used to
generate the list of terms for a given template.
@@ -165,42 +186,41 @@ using the [list templates](/templates/list/):
3. You can list all terms for a taxonomy
4. You can list all taxonomies (with their terms)
## 1. Displaying taxonomy terms assigned to this content
### Displaying a Single Piece of Content's Taxonomies
Within your content templates, you may wish to display
the taxonomies that that piece of content is assigned to.
Within your content templates, you may wish to display the taxonomies that piece of content is assigned to.
Because we are leveraging the front matter system to
define taxonomies for content, the taxonomies assigned to
each content piece are located in the usual place
Because we are leveraging the front matter system to define taxonomies for content, the taxonomies assigned to each content piece are located in the usual place
(.Params.`plural`).
### Example
<ul id="tags">
{{ range .Params.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
```html
<ul id="tags">
{{ range .Params.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
```
If you want to list taxonomies inline, you will have to take
care of optional plural ending in the title (if multiple taxonomies),
as well as commas. Let's say we have a taxonomy "directors" such as
`directors: [ "Joel Coen", "Ethan Coen" ]` in the TOML-format front matter.
To list such taxonomy use the following:
If you want to list taxonomies inline, you will have to take care of optional plural ending in the title (if multiple taxonomies), as well as commas. Let's say we have a taxonomy "directors" such as `directors: [ "Joel Coen", "Ethan Coen" ]` in the TOML-format front matter.
To list such taxonomies, use the following:
### Example
{{ if .Params.directors }}
<strong>Director{{ if gt (len .Params.directors) 1 }}s{{ end }}:</strong>
{{ range $index, $director := .Params.directors }}{{ if gt $index 0 }}, {{ end }}<a href="{{ "/directors/" | relURL }}{{ . | urlize }}">{{ . }}</a>{{ end }}
{{ end }}
```html
{{ if .Params.directors }}
<strong>Director{{ if gt (len .Params.directors) 1 }}s{{ end }}:</strong>
{{ range $index, $director := .Params.directors }}{{ if gt $index 0 }}, {{ end }}<a href="{{ "/directors/" | relURL }}{{ . | urlize }}">{{ . }}</a>{{ end }}
{{ end }}
```
Alternatively, you may use the [delimit](/templates/functions/) template function as a shortcut if the taxonomies should just be listed with a separator. See {{< gh 2143 >}} on GitHub for discussion.
Alternatively, you may use the [delimit](/functions/delimit/) template function as a shortcut if the taxonomies should just be listed with a separator. See {{< gh 2143 >}} on GitHub for discussion.
## 2. Listing content with the same taxonomy term
## 2. Listing content with the Same Taxonomy Term
First, you may be asking why you would use this. If you are using a taxonomy for something like a series of posts, this is exactly how you would do it. Its also an quick and dirty way to show some related content.
First, you may be asking why you would use this. If you are using a taxonomy for something like a series of posts, this is exactly how you would do it. Its also a quick and dirty way to show some related content.
### Example
@@ -214,30 +234,28 @@ First, you may be asking why you would use this. If you are using a taxonomy for
## 3. Listing all content in a given taxonomy
This would be very useful in a sidebar as “featured content”. You could
even have different sections of “featured content” by assigning
different terms to the content.
This would be very useful in a sidebar as “featured content”. You could even have different sections of “featured content” by assigning different terms to the content.
### Example
<section id="menu">
```html
<section id="menu">
<ul>
{{ range $key, $taxonomy := .Site.Taxonomies.featured }}
<li> {{ $key }} </li>
<ul>
{{ range $key, $taxonomy := .Site.Taxonomies.featured }}
<li> {{ $key }} </li>
<ul>
{{ range $taxonomy.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ range $taxonomy.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
</section>
{{ end }}
</ul>
</section>
```
## 4. Rendering a Site's Taxonomies
If you wish to display the list of all keys for a taxonomy, you can find retrieve
them from the `.Site` variable which is available on every page.
If you wish to display the list of all keys for a taxonomy, you can find retrieve them from the `.Site` variable which is available on every page.
This may take the form of a tag cloud, a menu or simply a list.
@@ -245,30 +263,40 @@ The following example displays all tag keys:
### Example
<ul id="all-tags">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ $name }}</a></li>
{{ end }}
</ul>
```html
<ul id="all-tags">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ $name }}</a></li>
{{ end }}
</ul>
```
### Complete Example
This example will list all taxonomies, each of their keys and all the content assigned to each key.
<section>
<ul>
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
<li><a href="{{ "/" | relLangURL}}{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a>
<ul>
{{ range $key, $value := $taxonomy }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
```html
<section>
<ul>
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
<li><a href="{{ "/" | relLangURL}}{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a>
<ul>
{{ range $key, $value := $taxonomy }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
```
## `.Site.GetPage` for Taxonomies
### `.Site.GetPage` Taxonomy List Example
### `.Site.GetPage` Taxonomy Terms Example
@@ -20,10 +20,10 @@ notesforauthors:
[Taxonomy terms pages][taxonomytemplates] are of the type `Page` and have the following additional variables. For example, the following fields would be available in `layouts/_defaults/terms.html`, depending on how you organize your [taxonomy templates][taxonomytemplates]:
`.Data.Singular`
: The singular name of the taxonomy
: The singular name of the taxonomy (e.g., `tags => `tag`)
`.Data.Plural`
: The plural name of the taxonomy
: The plural name of the taxonomy (e.g., `tags => tags`)
`.Data.Pages`
: The list of pages in the taxonomy
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -14,7 +14,7 @@
<tr>
<td>{{.Title}} <a href="{{.Permalink}}" title="See Web Page"><i class="fa fa-file-o" aria-hidden="true"></i></a> <a href="{{$ghrepo}}{{.File.Path}}" title="See Source" target="_blank"> <i class="fa fa-code" aria-hidden="true"></i></a></td>
<td>{{$section}}</td>
<td><code>{{ delimit .Aliases ", " }}<code></td>
<td><code>{{ delimit .Aliases ", " " and " }}<code></td>
{{end}}
</tr>
{{end}}
+7 -7
View File
@@ -1,9 +1,9 @@
{{ range .Params }}
{{ if eq (substr . 0 1) "@" }}
<a href="//github.com/{{ substr . 1 }}">{{ . }}</a>
{{ else if eq (substr . 0 2) "0x" }}
<a href="//github.com/spf13/hugo/commit/{{ substr . 2 }}">{{ substr . 2 6 }}</a>
{{ else }}
<a href="//github.com/spf13/hugo/issues/{{ . }}">#{{ . }}</a>
{{ end }}
{{ if eq (substr . 0 1) "@" }}
<a href="//github.com/{{ substr . 1 }}">{{ . }}</a>
{{ else if eq (substr . 0 2) "0x" }}
<a href="//github.com/spf13/hugo/commit/{{ substr . 2 }}">{{ substr . 2 6 }}</a>
{{ else }}
<a href="//github.com/spf13/hugo/issues/{{ . }}">#{{ . }}</a>
{{ end }}
{{ end }}
+1
View File
@@ -0,0 +1 @@
<a href="{{$.Site.Params.ghrepo}}" target="_blank">GitHub repository</a>
@@ -0,0 +1 @@
{{partial "lookup-explanation.html" . | markdownify}}
+1 -3
View File
@@ -1,6 +1,4 @@
<div class="note">
<h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}note{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Note{{end}}</h2>
<div class="shortcode-content">
{{.Inner}}
</div>
<div class="shortcode-content">{{- .Inner -}}</div>
</div>
+1 -3
View File
@@ -1,6 +1,4 @@
<div class="warning">
<h2>{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Warning{{end}}</h2>
<div class="shortcode-content">
{{.Inner}}
</div>
<div class="shortcode-content">{{- .Inner -}}</div>
</div>
@@ -0,0 +1,6 @@
Hugo uses a prioritized list called the *lookup order* as it traverses your files looking for the appropriate template to render your content. The template lookup order is an inverted cascade: if template A isnt present or specified, Hugo will look to template B. If template B isn't present or specified, Hugo will look for template C, and so on until it reaches the `layouts/_default/`` directory for your project, or in the case of themes, `themes/<yourchosentheme>/layouts/_default/`. In many ways, the lookup order is similar to the [control mechanism of a switch statement (without fallthrough)][switch] seen in many programming languages.
The power of the lookup order is that it enables you to craft specific layouts as needed without creating more templating than necessary, thereby keeping your templating [DRY][dry]. *Most sites will only need the default template files at the end of the lookup* (i.e. `_default/*.html`).
[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
[switch]: https://en.wikipedia.org/wiki/Switch_statement#Fallthrough
@@ -0,0 +1,17 @@
// #lookup-explanation {
// padding:0em;
// background-color: $hugo-blue-ultra-light;
// h2 {
// font-size: 1.3em;
// padding:0px;
// margin-bottom:0px;
// background-color: $hugo-blue;
// color:$hugo-white;
// }
// .inner-content {
// padding:.5em;
// p {
// margin-bottom:1em;
// }
// }
// }
+1
View File
@@ -33,6 +33,7 @@
@import 'components/breadcrumb';
@import 'components/tables';
@import 'vendor/featherlight.scss';
@import 'components/lookup-explanation';
//major layout parts/chrome
@import 'layout/site-header';
+2 -2
View File
@@ -1,4 +1,4 @@
**Content Files at a Glance**
## Content Files at a Glance
```
.
@@ -254,7 +254,7 @@
│   ├── pagination.md
│   ├── partial-templates.md
│   ├── rss-templates.md
│   ├── section-and-list-templates.md
│   ├── section-templates.md
│   ├── shortcode-templates.md
│   ├── single-page-templates.md
│   ├── sitemap-template.md