diff --git a/content/en/about/privacy.md b/content/en/about/privacy.md index dcc3b3439f..a3491f864c 100644 --- a/content/en/about/privacy.md +++ b/content/en/about/privacy.md @@ -15,7 +15,7 @@ aliases: [/gdpr/,/about/hugo-and-gdpr/] General Data Protection Regulation ([GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation)) is a regulation in EU law on data protection and privacy for all individuals within the European Union and the European Economic Area. It became enforceable on 25 May 2018. - **Hugo is a static site generator. By using Hugo you are already standing on very solid ground. Static HTML files on disk are much easier to reason about compared to server and database driven web sites.** + **Hugo is a static site generator. By using Hugo you are already standing on very solid ground. Static HTML files on disk are much easier to reason about compared to server and database driven websites.** But even static websites can integrate with external services, so from version `0.41`, Hugo provides a **privacy configuration** that covers the relevant built-in templates. diff --git a/content/en/content-management/comments.md b/content/en/content-management/comments.md index 8f55c413c9..721f1fe5a0 100644 --- a/content/en/content-management/comments.md +++ b/content/en/content-management/comments.md @@ -74,5 +74,5 @@ Open-source commenting systems: [front matter]: /content-management/front-matter/ [kaijuissue]: https://github.com/spf13/kaiju/issues/new [issotutorial]: https://stiobhart.net/2017-02-24-isso-comments/ -[partials]: /templates/partials/ +[partials]: /templates/partial/ [MongoDB]: https://www.mongodb.com/ diff --git a/content/en/content-management/content-adapters.md b/content/en/content-management/content-adapters.md index 11257b8956..ea5ec62caf 100644 --- a/content/en/content-management/content-adapters.md +++ b/content/en/content-management/content-adapters.md @@ -241,7 +241,7 @@ Step 3 {{< /code >}} Step 4 -: Create a single page template to render each book review. +: Create a single template to render each book review. {{< code file=layouts/books/single.html copy=true >}} {{ define "main" }} diff --git a/content/en/content-management/cross-references.md b/content/en/content-management/cross-references.md index 24da0bfda8..124a3bf06a 100644 --- a/content/en/content-management/cross-references.md +++ b/content/en/content-management/cross-references.md @@ -36,12 +36,12 @@ The `ref` and `relref` shortcodes require a single argument: the path to a conte The pages can be referenced as follows: ```text -{{}} // <- From pages/document1.md, relative path +{{}} <-- From pages/document1.md, relative path {{}} {{}} {{}} -{{}} // <- From pages/document2.md -{{}} // <- From anywhere, absolute path +{{}} <-- From pages/document2.md +{{}} <-- From anywhere, absolute path {{}} {{}} {{}} @@ -52,12 +52,12 @@ The pages can be referenced as follows: index.md can be reference either by its path or by its containing folder without the ending `/`. \_index.md can be referenced only by its containing folder: ```text -{{}} // <- References /about/_index.md -{{}} // Raises REF_NOT_FOUND error -{{}} // <- References /about/credits.md +{{}} <-- References /about/_index.md +{{}} <-- Raises REF_NOT_FOUND error +{{}} <-- References /about/credits.md -{{}} // <- References /products/index.md -{{}} // <- References /products/index.md +{{}} <-- References /products/index.md +{{}} <-- References /products/index.md ``` To generate a hyperlink using `ref` or `relref` in Markdown: @@ -146,7 +146,3 @@ refLinksErrorLevel ("ERROR") refLinksNotFoundURL : URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is. - -[lists]: /templates/lists/ -[output formats]: /templates/output-formats/ -[shortcode]: /content-management/shortcodes/ diff --git a/content/en/content-management/front-matter.md b/content/en/content-management/front-matter.md index 2c01f78546..3ac2a63bcf 100644 --- a/content/en/content-management/front-matter.md +++ b/content/en/content-management/front-matter.md @@ -207,7 +207,7 @@ path (`map`) A map of sitemap options. See the [sitemap templates] page for details. Access these values from a template using the [`Sitemap`] method on a `Page` object. -[sitemap templates]: /templates/sitemap-template/ +[sitemap templates]: /templates/sitemap/ [`sitemap`]: /methods/page/sitemap/ ###### slug diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md index 292aa8a4d5..b5309232cb 100644 --- a/content/en/content-management/image-processing/index.md +++ b/content/en/content-management/image-processing/index.md @@ -59,7 +59,7 @@ A remote resource is a file on a remote server, accessible via HTTP or HTTPS. To ## Image rendering -Once you have accessed an image as either a page resource or a global resource, render it in your templates using the `Permalink`, `RelPermalink`, `Width`, and `Height` properties. +Once you have accessed an image as a resource, render it in your templates using the `Permalink`, `RelPermalink`, `Width`, and `Height` properties. Example 1: Throws an error if the resource is not found. diff --git a/content/en/content-management/menus.md b/content/en/content-management/menus.md index 1f8595816b..169b6eb057 100644 --- a/content/en/content-management/menus.md +++ b/content/en/content-management/menus.md @@ -227,7 +227,7 @@ Hugo provides two methods to localize your menu entries. See [multilingual]. See [menu templates]. [localize]: /content-management/multilingual/#menus -[menu templates]: /templates/menu-templates/ +[menu templates]: /templates/menu/ [multilingual]: /content-management/multilingual/#menus [section]: /getting-started/glossary/#section -[template]: /templates/menu-templates/ +[template]: /templates/menu/ diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md index 22e2c186ab..d7f6ec7d68 100644 --- a/content/en/content-management/multilingual.md +++ b/content/en/content-management/multilingual.md @@ -322,7 +322,7 @@ To create a list of links to translated content, use a template similar to the f {{ end }} {{< /code >}} -The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template, whether a [single content page][contenttemplate] or the [homepage]. It will not print anything if there are no translations for a given page. +The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template. It will not print anything if there are no translations for a given page. The above also uses the [`i18n` function][i18func] described in the next section. @@ -564,7 +564,7 @@ products = 'Produkte' services = 'Leistungen' {{< / code-toggle >}} -[example menu template]: /templates/menu-templates/#example +[example menu template]: /templates/menu/#example [automatically]: /content-management/menus/#define-automatically [in front matter]: /content-management/menus/#define-in-front-matter [in site configuration]: /content-management/menus/#define-in-site-configuration @@ -615,10 +615,8 @@ hugo new content content/de/post/test.md [`abslangurl`]: /functions/urls/abslangurl/ [config]: /getting-started/configuration/ -[contenttemplate]: /templates/single-page-templates/ [go-i18n-source]: https://github.com/nicksnyder/go-i18n [go-i18n]: https://github.com/nicksnyder/go-i18n -[homepage]: /templates/homepage/ [Hugo Multilingual Part 1: Content translation]: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/ [i18func]: /functions/lang/translate/ [lang.FormatAccounting]: /functions/lang/formataccounting/ @@ -630,5 +628,4 @@ hugo new content content/de/post/test.md [menus]: /content-management/menus/ [OS environment]: /getting-started/configuration/#configure-with-environment-variables [`rellangurl`]: /functions/urls/rellangurl/ -[single page templates]: /templates/single-page-templates/ [`time.Format`]: /functions/time/format/ diff --git a/content/en/content-management/organization/index.md b/content/en/content-management/organization/index.md index e286462d7e..99a3224bf6 100644 --- a/content/en/content-management/organization/index.md +++ b/content/en/content-management/organization/index.md @@ -71,13 +71,13 @@ The following demonstrates the relationships between your content organization a ### Index pages: `_index.md` -`_index.md` has a special role in Hugo. It allows you to add front matter and content to your [list templates][lists]. These templates include those for [section templates], [taxonomy templates], [taxonomy terms templates], and your [homepage template]. +`_index.md` has a special role in Hugo. It allows you to add front matter and content to `home`, `section`, `taxonomy`, and `term` pages. {{% note %}} **Tip:** You can get a reference to the content and metadata in `_index.md` using the [`.Site.GetPage` function](/methods/page/getpage). {{% /note %}} -You can create one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website: +You can create one `_index.md` for your home page and one in each of your content sections, taxonomies, and terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website: ```txt . url @@ -106,7 +106,7 @@ The [sections] can be nested as deeply as you want. The important thing to under ### Single pages in sections -Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`: +Single content files in each of your sections will be rendered by a [single template]. Here is an example of a single `post` within `posts`: ```txt path ("posts/my-first-hugo-post.md") @@ -156,14 +156,7 @@ The `url` is the entire URL path, defined by the file path and optionally overri [formats]: /content-management/formats/ [front matter]: /content-management/front-matter/ [getpage]: /methods/page/getpage/ -[homepage template]: /templates/homepage/ -[homepage]: /templates/homepage/ -[lists]: /templates/lists/ [pretty]: /content-management/urls/#appearance -[section templates]: /templates/section-templates/ [sections]: /content-management/sections/ -[singles]: /templates/single-page-templates/ -[taxonomy templates]: /templates/taxonomy-templates/ -[taxonomy terms templates]: /templates/taxonomy-templates/ -[types]: /content-management/types/ +[single template]: /templates/types/#single [urls]: /content-management/urls/ diff --git a/content/en/content-management/page-bundles.md b/content/en/content-management/page-bundles.md index af7c2ce14d..b83bb0ba57 100644 --- a/content/en/content-management/page-bundles.md +++ b/content/en/content-management/page-bundles.md @@ -50,11 +50,17 @@ Page bundle characteristics vary by bundle type. | Index file | index.md | _index.md | | Example | content/about/index.md | content/posts/_index.md | | [Page kinds] | `page` | `home`, `section`, `taxonomy`, or `term` | -| Layout type | [single] | [list] | +| Template types | [single] | [home], [section], [taxonomy], or [term] | | Descendant pages | None | Zero or more | | Resource location | Adjacent to the index file or in a nested subdirectory | Same as a leaf bundles, but excludes descendant bundles | | [Resource types] | `page`, `image`, `video`, etc. | all but `page` | +[single]: /templates/types/#single +[home]: /templates/types/#home +[section]: /templates/types/#section +[taxonomy]: /templates/types/#taxonomy +[term]: /templates/types/#term + Files with [resource type] `page` include content written in Markdown, HTML, AsciiDoc, Pandoc, reStructuredText, and Emacs Org Mode. In a leaf bundle, excluding the index file, these files are only accessible as page resources. In a branch bundle, these files are only accessible as content pages. ## Leaf bundles @@ -149,9 +155,7 @@ Use [build options] in front matter to create an unpublished leaf or branch bund [`Resources`]: /methods/page/resources/ [build options]: content-management/build-options/ -[list]: /templates/lists/ [page kinds]: /getting-started/glossary/#page-kind [page resources]: /content-management/page-resources/ [resource type]: /getting-started/glossary/#resource-type [resource types]: /getting-started/glossary/#resource-type -[single]: /templates/single-page-templates/ diff --git a/content/en/content-management/related.md b/content/en/content-management/related.md index 478b55a993..0a97bd7cb0 100644 --- a/content/en/content-management/related.md +++ b/content/en/content-management/related.md @@ -16,7 +16,7 @@ Hugo uses a set of factors to identify a page's related content based on front m ## List related content -To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your single page template: +To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your template: {{< code file=layouts/partials/related.html >}} {{ $related := .Site.RegularPages.Related . | first 5 }} diff --git a/content/en/content-management/sections.md b/content/en/content-management/sections.md index 0c2f8f0e27..03655c90ae 100644 --- a/content/en/content-management/sections.md +++ b/content/en/content-management/sections.md @@ -90,13 +90,13 @@ Hugo has a defined [lookup order] to determine which template to use when render With the file structure from the [example above](#overview): -Content directory|List page template +Content directory|Section template :--|:-- content/products|layouts/products/list.html content/products/product-1|layouts/products/list.html content/products/product-1/benefits|layouts/products/list.html -Content directory|Single page template +Content directory|Single template :--|:-- content/products|layouts/products/single.html content/products/product-1|layouts/products/single.html @@ -159,6 +159,6 @@ Home » Products » Product 1 » Benefits » Benefit 1 [archetype]: /content-management/archetypes/ [content type]: /content-management/types/ [directory structure]: /getting-started/directory-structure/ -[section templates]: /templates/section-templates/ +[section templates]: /templates/types/#section [leaf bundles]: /content-management/page-bundles/#leaf-bundles [branch bundles]: /content-management/page-bundles/#branch-bundles diff --git a/content/en/content-management/shortcodes.md b/content/en/content-management/shortcodes.md index 87c9f08255..847ba2bbbe 100644 --- a/content/en/content-management/shortcodes.md +++ b/content/en/content-management/shortcodes.md @@ -469,9 +469,9 @@ To learn how to configure your Hugo site to meet the new EU privacy regulation, To learn more about creating custom shortcodes, see the [shortcode template documentation]. [privacy protections]: /about/privacy/ -[partials]: /templates/partials/ +[partials]: /templates/partial/ [quickstart]: /getting-started/quick-start/ -[sctemps]: /templates/shortcode-templates/ -[shortcode template documentation]: /templates/shortcode-templates/ +[sctemps]: /templates/shortcode/ +[shortcode template documentation]: /templates/shortcode/ [Vimeo]: https://vimeo.com/ [YouTube Videos]: https://www.youtube.com/ diff --git a/content/en/content-management/taxonomies.md b/content/en/content-management/taxonomies.md index 764e41a8fc..6ba9e2a25f 100644 --- a/content/en/content-management/taxonomies.md +++ b/content/en/content-management/taxonomies.md @@ -95,7 +95,7 @@ disableKinds = ["taxonomy","term"] When taxonomies are used---and [taxonomy templates] are provided---Hugo will automatically create both a page listing all the taxonomy's terms and individual pages with lists of content associated with each term. For example, a `categories` taxonomy declared in your configuration and used in your content front matter will create the following pages: -* A single page at `example.com/categories/` that lists all the [terms within the taxonomy] +* A single page at `example.com/categories/` that lists all the terms within the taxonomy * [Individual taxonomy list pages][taxonomy templates] (e.g., `/categories/development/`) for each of the terms that shows a listing of all pages marked as part of that taxonomy within any content file's [front matter] ## Configure taxonomies @@ -142,7 +142,7 @@ categories = ['Category A','Category B'] ## Order taxonomies -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`. +A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy templates] and is declared in a content file's [front matter]. The convention for declaring taxonomic weight is `taxonomyname_weight`. The following 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. @@ -171,7 +171,5 @@ wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis" [content type]: /content-management/types/ [documentation on archetypes]: /content-management/archetypes/ [front matter]: /content-management/front-matter/ -[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-templates -[taxonomy templates]: /templates/taxonomy-templates/ -[terms within the taxonomy]: /templates/taxonomy-templates/#term-templates +[taxonomy templates]: /templates/types/#taxonomy [site configuration]: /getting-started/configuration/ diff --git a/content/en/content-management/types.md b/content/en/content-management/types.md index 67dbe15969..9b44645e9f 100644 --- a/content/en/content-management/types.md +++ b/content/en/content-management/types.md @@ -16,5 +16,5 @@ A **content type** is a way to organize your content. Hugo resolves the content A content type is used to -- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](/templates/views) for more. +- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](/templates/content-view) for more. - Determine which [archetype](/content-management/archetypes/) template to use for new content. diff --git a/content/en/contribute/development.md b/content/en/contribute/development.md index 07d4c44572..f6ff44ced0 100644 --- a/content/en/contribute/development.md +++ b/content/en/contribute/development.md @@ -158,7 +158,7 @@ CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest To build and install a specific release: ```sh -CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.126.0 +CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.128.0 ``` To build and install at the latest commit on the master branch: diff --git a/content/en/contribute/documentation.md b/content/en/contribute/documentation.md index 61c603d6c3..408ed505d9 100644 --- a/content/en/contribute/documentation.md +++ b/content/en/contribute/documentation.md @@ -44,6 +44,8 @@ Although we do not strictly adhere to the [Microsoft Writing Style Guide], it is Please link to the [glossary of terms] when necessary, and use the terms consistently throughout the documentation. Of special note: - The term "front matter" is two words unless you are referring to the configuration key +- The term "home page" is two words +- The term "website" is one word - The term "standalone" is one word, not hyphenated - Use the word "map" instead of "dictionary" - Use the word "flag" instead of "option" when referring to a command line flag diff --git a/content/en/functions/collections/After.md b/content/en/functions/collections/After.md index 38cf755a0d..751ad0bef6 100644 --- a/content/en/functions/collections/After.md +++ b/content/en/functions/collections/After.md @@ -35,7 +35,7 @@ The template above is rendered to: ## Example of `after` with `first`: 2nd–4th most recent articles -You can use `after` in combination with the [`first`] function and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page] to show only two rows: +You can use `after` in combination with the [`first`] function and Hugo's [powerful sorting methods](/quick-reference/page-collections/#sort). Let's assume you have a `section` page at `example.com/articles`. You have 10 articles, but you want your template to show only two rows: 1. The top row is titled "Featured" and shows only the most recently published article (i.e. by `publishdate` in the content files' front matter). 2. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles. @@ -66,6 +66,4 @@ You can use `after` in combination with the [`first`] function and Hugo's [power {{< /code >}} [`first`]: /functions/collections/first/ -[list/section page]: /templates/section-templates/ -[lists]: /templates/lists/#sort-content [`slice`]: /functions/collections/slice/ diff --git a/content/en/functions/collections/Group.md b/content/en/functions/collections/Group.md index 7bbd95f034..0ec45516c2 100644 --- a/content/en/functions/collections/Group.md +++ b/content/en/functions/collections/Group.md @@ -28,4 +28,4 @@ aliases: [/functions/group] {{ end }} ``` -The page group you get from `group` is of the same type you get from the built-in [group methods](/templates/lists#group-content) in Hugo. The example above can be [paginated](/templates/pagination/). +The page group you get from `group` is of the same type you get from the built-in [group methods](/quick-reference/page-collections/#group) in Hugo. The example above can be [paginated](/templates/pagination/). diff --git a/content/en/functions/collections/Intersect.md b/content/en/functions/collections/Intersect.md index 8bc60f8e1e..9e9cc0c765 100644 --- a/content/en/functions/collections/Intersect.md +++ b/content/en/functions/collections/Intersect.md @@ -25,6 +25,3 @@ A useful example is to use it as `AND` filters when combined with where: The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters. See [union](/functions/collections/union) for `OR`. - -[partials]: /templates/partials/ -[single]: /templates/single-page-templates/ diff --git a/content/en/functions/crypto/FNV32a.md b/content/en/functions/crypto/FNV32a.md index c1e04183d2..eda303e62d 100644 --- a/content/en/functions/crypto/FNV32a.md +++ b/content/en/functions/crypto/FNV32a.md @@ -15,8 +15,6 @@ action: aliases: [/functions/crypto.fnv32a] --- -{{< new-in 0.98.0 >}} - This function calculates the 32-bit [FNV1a hash](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) of a given string according to the [specification](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-12): ```go-html-template diff --git a/content/en/functions/css/Sass.md b/content/en/functions/css/Sass.md index 2ff796436d..ef1572ae0f 100644 --- a/content/en/functions/css/Sass.md +++ b/content/en/functions/css/Sass.md @@ -141,8 +141,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file ```yaml variables: - HUGO_VERSION: 0.126.0 - DART_SASS_VERSION: 1.77.1 + HUGO_VERSION: 0.128.0 + DART_SASS_VERSION: 1.77.5 GIT_DEPTH: 0 GIT_STRATEGY: clone GIT_SUBMODULE_STRATEGY: recursive @@ -175,8 +175,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should ```toml [build.environment] -HUGO_VERSION = "0.126.0" -DART_SASS_VERSION = "1.77.1" +HUGO_VERSION = "0.128.0" +DART_SASS_VERSION = "1.77.5" TZ = "America/Los_Angeles" [build] diff --git a/content/en/functions/css/TailwindCSS.md b/content/en/functions/css/TailwindCSS.md index 8f356e336a..f09726fb79 100644 --- a/content/en/functions/css/TailwindCSS.md +++ b/content/en/functions/css/TailwindCSS.md @@ -79,3 +79,7 @@ Process the resource: ``` The example above publishes the minified CSS file to public/css/main.css. + +See [this repository] for more information about the integration with Tailwind CSS v4.0. + +[this repository]: https://github.com/bep/hugo-testing-tailwindcss-v4 diff --git a/content/en/functions/global/page.md b/content/en/functions/global/page.md index b7a8161dc9..b952597b2d 100644 --- a/content/en/functions/global/page.md +++ b/content/en/functions/global/page.md @@ -58,7 +58,7 @@ content/ └── _index.md <-- title is "My Home Page" ``` -And this code in the home page template: +And this code in the home template: ```go-html-template {{ range site.Sections }} @@ -76,7 +76,7 @@ My Home Page My Home Page ``` -In the example above, the global `page` function accesses the `Page` object passed into the home page template; it does not access the `Page` object of the iterated pages. +In the example above, the global `page` function accesses the `Page` object passed into the home template; it does not access the `Page` object of the iterated pages. ### Be aware of caching diff --git a/content/en/functions/go-template/return.md b/content/en/functions/go-template/return.md index e09522a588..6916827e6f 100644 --- a/content/en/functions/go-template/return.md +++ b/content/en/functions/go-template/return.md @@ -75,7 +75,7 @@ Hugo renders: See additional examples in the [partial templates] section. -[partial templates]: /templates/partials/#returning-a-value-from-a-partial +[partial templates]: /templates/partial/#returning-a-value-from-a-partial ## Usage diff --git a/content/en/functions/go-template/template.md b/content/en/functions/go-template/template.md index 687d8b0c89..0a72acdaa8 100644 --- a/content/en/functions/go-template/template.md +++ b/content/en/functions/go-template/template.md @@ -45,5 +45,5 @@ The example above can be rewritten using an [inline partial] template: {{% include "functions/go-template/_common/text-template.md" %}} [`partial`]: /functions/partials/include/ -[inline partial]: /templates/partials/#inline-partials +[inline partial]: /templates/partial/#inline-partials [embedded templates]: /templates/embedded/ diff --git a/content/en/functions/hugo/Generator.md b/content/en/functions/hugo/Generator.md index 3bf74fd61d..5538903ed6 100644 --- a/content/en/functions/hugo/Generator.md +++ b/content/en/functions/hugo/Generator.md @@ -11,5 +11,5 @@ action: --- ```go-html-template -{{ hugo.Generator }} → +{{ hugo.Generator }} → ``` diff --git a/content/en/functions/hugo/Version.md b/content/en/functions/hugo/Version.md index e839536459..988e8ad883 100644 --- a/content/en/functions/hugo/Version.md +++ b/content/en/functions/hugo/Version.md @@ -11,5 +11,5 @@ action: --- ```go-html-template -{{ hugo.Version }} → 0.126.0 +{{ hugo.Version }} → 0.128.0 ``` diff --git a/content/en/functions/resources/ByType.md b/content/en/functions/resources/ByType.md index bc5cca533c..dc3bc9c9ce 100644 --- a/content/en/functions/resources/ByType.md +++ b/content/en/functions/resources/ByType.md @@ -26,7 +26,7 @@ The [media type] is typically one of `image`, `text`, `audio`, `video`, or `appl {{% note %}} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory. -For page resources, use the [`Resources.ByType`] method on the Page object. +For page resources, use the [`Resources.ByType`] method on a `Page` object. [`Resources.ByType`]: /methods/page/resources/ {{% /note %}} diff --git a/content/en/functions/resources/FromString.md b/content/en/functions/resources/FromString.md index 1ab3f32008..8801de6e40 100644 --- a/content/en/functions/resources/FromString.md +++ b/content/en/functions/resources/FromString.md @@ -24,7 +24,7 @@ Let's say you need to publish a file named "site.json" in the root of your publi ```json { "build_date": "2024-02-19T12:27:05-08:00", - "hugo_version": "0.126.0", + "hugo_version": "0.128.0", "last_modified": "2024-02-19T12:01:42-08:00" } ``` diff --git a/content/en/functions/resources/Get.md b/content/en/functions/resources/Get.md index 3ae291c422..0678c4b0da 100644 --- a/content/en/functions/resources/Get.md +++ b/content/en/functions/resources/Get.md @@ -24,7 +24,7 @@ action: {{% note %}} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory. -For page resources, use the [`Resources.Get`] method on the Page object. +For page resources, use the [`Resources.Get`] method on a `Page` object. [`Resources.Get`]: /methods/page/resources/ {{% /note %}} diff --git a/content/en/functions/resources/GetMatch.md b/content/en/functions/resources/GetMatch.md index aa2f1ccbbf..749867b41f 100644 --- a/content/en/functions/resources/GetMatch.md +++ b/content/en/functions/resources/GetMatch.md @@ -24,7 +24,7 @@ action: {{% note %}} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory. -For page resources, use the [`Resources.GetMatch`] method on the Page object. +For page resources, use the [`Resources.GetMatch`] method on a `Page` object. [`Resources.GetMatch`]: /methods/page/resources/ {{% /note %}} diff --git a/content/en/functions/resources/Match.md b/content/en/functions/resources/Match.md index f23d56f638..49c7e7df2c 100644 --- a/content/en/functions/resources/Match.md +++ b/content/en/functions/resources/Match.md @@ -24,7 +24,7 @@ action: {{% note %}} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory. -For page resources, use the [`Resources.Match`] method on the Page object. +For page resources, use the [`Resources.Match`] method on a `Page` object. [`Resources.Match`]: /methods/page/resources/ {{% /note %}} diff --git a/content/en/functions/resources/ToCSS.md b/content/en/functions/resources/ToCSS.md index fe3f62b131..b6f72e908b 100644 --- a/content/en/functions/resources/ToCSS.md +++ b/content/en/functions/resources/ToCSS.md @@ -146,8 +146,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file ```yaml variables: - HUGO_VERSION: 0.126.0 - DART_SASS_VERSION: 1.77.1 + HUGO_VERSION: 0.128.0 + DART_SASS_VERSION: 1.77.5 GIT_DEPTH: 0 GIT_STRATEGY: clone GIT_SUBMODULE_STRATEGY: recursive @@ -180,8 +180,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should ```toml [build.environment] -HUGO_VERSION = "0.126.0" -DART_SASS_VERSION = "1.77.1" +HUGO_VERSION = "0.128.0" +DART_SASS_VERSION = "1.77.5" TZ = "America/Los_Angeles" [build] diff --git a/content/en/functions/transform/Emojify.md b/content/en/functions/transform/Emojify.md index d9f0adf67d..8422a0c780 100644 --- a/content/en/functions/transform/Emojify.md +++ b/content/en/functions/transform/Emojify.md @@ -26,5 +26,5 @@ I :heart: Hugo! [configuration]: /getting-started/configuration/ [emoji shortcodes]: /quick-reference/emojis/ -[sc]: /templates/shortcode-templates/ +[sc]: /templates/shortcode/ [scsource]: https://github.com/gohugoio/hugo/tree/master/docs/layouts/shortcodes diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index ed5fdf032c..13474c7707 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -438,7 +438,7 @@ See [Segments](#configure-segments). ###### sitemap -Default [sitemap configuration](/templates/sitemap-template/#configuration). +Default [sitemap configuration](/templates/sitemap/#configuration). ###### summaryLength diff --git a/content/en/getting-started/glossary.md b/content/en/getting-started/glossary.md index 561f7621b1..cdd9c58eed 100644 --- a/content/en/getting-started/glossary.md +++ b/content/en/getting-started/glossary.md @@ -104,7 +104,7 @@ A classification of content inferred from the top-level directory name or the `t ###### content view -A template called with the `.Page.Render` method. See [details](/templates/views/). +A template called with the `.Page.Render` method. See [details](/templates/content-view/). ###### context @@ -132,7 +132,6 @@ To determine the current environment within a template, use the [`hugo.Environme A predefined key-value pair in front matter such as `date` or `title`. See also [parameter](#parameter). - ###### flag An option passed to a command-line program, beginning with one or two hyphens. See [details](/commands/hugo/). @@ -212,6 +211,10 @@ A directory that contains an index.md file and zero or more [resources](#resourc Any [page kind](#page-kind) that receives a page [collection](#collection) in [context](#context). This includes the home page, [section pages](#section-page), [taxonomy pages](#taxonomy-page), and [term pages](#term-page). +###### list template + +Any template that renders a [list page](#list-page). This includes [home](/templates/types/#home), [section](/templates/types/#section), [taxonomy](/templates/types/#taxonomy), and [term](/templates/types/#term) templates. + ###### localization Adaptation of a site to meet language and regional requirements. This includes translations, language-specific media, date and currency formats, etc. See [details](/content-management/multilingual/) and the [W3C definition](https://www.w3.org/International/questions/qa-i18n). Abbreviated l10n. @@ -256,7 +259,7 @@ A data structure with or without associated [methods](#method). ###### ordered taxonomy -Created by invoking the [`Alphabetical`] or [`ByCount`] method on a [taxonomy object](#taxonomy-object), which is a [map](#map), an ordered taxonomy is a [slice](#slice), where each element is an object that contains the [term](#term) and a slice of its [weighted pages](#weighted-page). +Created by invoking the [`Alphabetical`] or [`ByCount`] method on a [`Taxonomy`](#taxonomy-object) object, which is a [map](#map), an ordered taxonomy is a [slice](#slice), where each element is an object that contains the [term](#term) and a slice of its [weighted pages](#weighted-page). [`Alphabetical`]: /methods/taxonomy/alphabetical/ [`ByCount`]: /methods/taxonomy/bycount/ @@ -271,7 +274,7 @@ A directory that encapsulates both content and associated [resources](#resource) ###### page collection -A slice of page objects. +A slice of `Page` objects. ###### page kind @@ -398,7 +401,7 @@ Raw string literals are character sequences between backticks, as in \`bar\`. Wi ###### taxonomic weight -Defined in front matter and unique to each taxonomy, this [weight](#weight) determines the sort order of page collections contained within a [taxonomy object](#taxonomy-object). See [details](/templates/taxonomy-templates/#assign-weight). +Defined in front matter and unique to each taxonomy, this [weight](#weight) determines the sort order of page collections contained within a [`Taxonomy`](#taxonomy-object) object. See [details](/content-management/taxonomies/#order-taxonomies). ###### taxonomy @@ -458,7 +461,7 @@ Used to position an element within a collection sorted by weight. Assign weights ###### weighted page -Contained within a [taxonomy object](#taxonomy-object), a weighted page is a [map](#map) with two elements: a `Page` object, and its [taxonomic weight](#taxonomic-weight) as defined in front matter. Access the elements using the `Page` and `Weight` keys. +Contained within a [`Taxonomy`](#taxonomy-object) object, a weighted page is a [map](#map) with two elements: a `Page` object, and its [taxonomic weight](#taxonomic-weight) as defined in front matter. Access the elements using the `Page` and `Weight` keys. ###### zero time diff --git a/content/en/hosting-and-deployment/deployment-with-rsync.md b/content/en/hosting-and-deployment/deployment-with-rsync.md index f341ad6189..06f250b377 100644 --- a/content/en/hosting-and-deployment/deployment-with-rsync.md +++ b/content/en/hosting-and-deployment/deployment-with-rsync.md @@ -89,7 +89,7 @@ Add the following content. Replace the `USER`, `HOST`, and `DIR` values with you #!/bin/sh USER=my-user HOST=my-server.com -DIR=my/directory/to/topologix.fr/ # the directory where your web site files should go +DIR=my/directory/to/topologix.fr/ # the directory where your website files should go hugo && rsync -avz --delete public/ ${USER}@${HOST}:~/${DIR} # this will delete everything on the server that's not in the local public folder diff --git a/content/en/hosting-and-deployment/hosting-on-github/index.md b/content/en/hosting-and-deployment/hosting-on-github/index.md index 5460193a70..1ac768178a 100644 --- a/content/en/hosting-and-deployment/hosting-on-github/index.md +++ b/content/en/hosting-and-deployment/hosting-on-github/index.md @@ -97,7 +97,7 @@ jobs: build: runs-on: ubuntu-latest env: - HUGO_VERSION: 0.127.0 + HUGO_VERSION: 0.128.0 steps: - name: Install Hugo CLI run: | diff --git a/content/en/hosting-and-deployment/hosting-on-gitlab.md b/content/en/hosting-and-deployment/hosting-on-gitlab.md index c628922cdc..440bbc13dd 100644 --- a/content/en/hosting-and-deployment/hosting-on-gitlab.md +++ b/content/en/hosting-and-deployment/hosting-on-gitlab.md @@ -27,8 +27,8 @@ Define your [CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) jobs by creating {{< code file=.gitlab-ci.yml copy=true >}} variables: - DART_SASS_VERSION: 1.77.1 - HUGO_VERSION: 0.126.0 + DART_SASS_VERSION: 1.77.5 + HUGO_VERSION: 0.128.0 NODE_VERSION: 20.x GIT_DEPTH: 0 GIT_STRATEGY: clone diff --git a/content/en/hosting-and-deployment/hosting-on-netlify/index.md b/content/en/hosting-and-deployment/hosting-on-netlify/index.md index b297bca028..66382b7e3f 100644 --- a/content/en/hosting-and-deployment/hosting-on-netlify/index.md +++ b/content/en/hosting-and-deployment/hosting-on-netlify/index.md @@ -101,7 +101,7 @@ Create a new file named netlify.toml in the root of your project directory. In i {{< code file=netlify.toml >}} [build.environment] -HUGO_VERSION = "0.126.0" +HUGO_VERSION = "0.128.0" TZ = "America/Los_Angeles" [build] @@ -113,8 +113,8 @@ If your site requires Dart Sass to transpile Sass to CSS, the configuration file {{< code file=netlify.toml >}} [build.environment] -HUGO_VERSION = "0.126.0" -DART_SASS_VERSION = "1.77.1" +HUGO_VERSION = "0.128.0" +DART_SASS_VERSION = "1.77.5" TZ = "America/Los_Angeles" [build] diff --git a/content/en/hugo-pipes/transpile-sass-to-css.md b/content/en/hugo-pipes/transpile-sass-to-css.md index 0e0f7d815c..ee4b1295da 100644 --- a/content/en/hugo-pipes/transpile-sass-to-css.md +++ b/content/en/hugo-pipes/transpile-sass-to-css.md @@ -136,8 +136,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file ```yaml variables: - HUGO_VERSION: 0.126.0 - DART_SASS_VERSION: 1.77.1 + HUGO_VERSION: 0.128.0 + DART_SASS_VERSION: 1.77.5 GIT_DEPTH: 0 GIT_STRATEGY: clone GIT_SUBMODULE_STRATEGY: recursive @@ -170,8 +170,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should ```toml [build.environment] -HUGO_VERSION = "0.122.2" -DART_SASS_VERSION = "1.77.1" +HUGO_VERSION = "0.128.0" +DART_SASS_VERSION = "1.77.5" TZ = "America/Los_Angeles" [build] diff --git a/content/en/methods/menu-entry/Menu.md b/content/en/methods/menu-entry/Menu.md index 63f148c1a3..79b400f1fd 100644 --- a/content/en/methods/menu-entry/Menu.md +++ b/content/en/methods/menu-entry/Menu.md @@ -21,4 +21,4 @@ Use this method with the [`IsMenuCurrent`] and [`HasMenuCurrent`] methods on a ` [`HasMenuCurrent`]: /methods/page/hasmenucurrent/ [`IsMenuCurrent`]: /methods/page/ismenucurrent/ -[this example]: /templates/menu-templates/#example +[this example]: /templates/menu/#example diff --git a/content/en/methods/menu-entry/Page.md b/content/en/methods/menu-entry/Page.md index bd8c1625ec..d177a1af0b 100644 --- a/content/en/methods/menu-entry/Page.md +++ b/content/en/methods/menu-entry/Page.md @@ -49,5 +49,5 @@ See the [menu templates] section for more information. [`LinkTitle`]: /methods/page/linktitle/ [`RelPermalink`]: /methods/page/relpermalink/ [define menu entries]: /content-management/menus/ -[menu templates]: /templates/menu-templates/#page-references +[menu templates]: /templates/menu/#page-references [methods]: /methods/page/ diff --git a/content/en/methods/menu-entry/Params.md b/content/en/methods/menu-entry/Params.md index 8af3f0637b..5c1d3c2d03 100644 --- a/content/en/methods/menu-entry/Params.md +++ b/content/en/methods/menu-entry/Params.md @@ -57,6 +57,6 @@ Hugo renders: See the [menu templates] section for more information. -[menu templates]: /templates/menu-templates/#menu-entry-parameters +[menu templates]: /templates/menu/#menu-entry-parameters [in front matter]: /content-management/menus/#define-in-front-matter [in site configuration]: /content-management/menus/ diff --git a/content/en/methods/page/Data.md b/content/en/methods/page/Data.md index aea1042d45..b8259ffa87 100644 --- a/content/en/methods/page/Data.md +++ b/content/en/methods/page/Data.md @@ -65,14 +65,14 @@ Plural ``` Terms -: (`page.Taxonomy`) Returns the taxonomy object, consisting of a map of terms and the [weighted pages] associated with each term. +: (`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages] associated with each term. ```go-html-template {{ $taxonomyObject := .Data.Terms }} ``` {{% note %}} -Once you have captured the taxonomy object, use any of the [taxonomy methods] to sort, count, or capture a subset of its weighted pages. +Once you have captured the `Taxonomy` object, use any of the [taxonomy methods] to sort, count, or capture a subset of its weighted pages. [taxonomy methods]: /methods/taxonomy/ {{% /note %}} @@ -106,6 +106,6 @@ Term Learn more about [term templates]. -[taxonomy templates]: /templates/taxonomy-templates/ -[term templates]: /templates/taxonomy-templates/ +[taxonomy templates]: /templates/types/#taxonomy +[term templates]: /templates/types/#term [weighted pages]: /getting-started/glossary/#weighted-page diff --git a/content/en/methods/page/Eq.md b/content/en/methods/page/Eq.md index 1be4162950..99a9fc50ff 100644 --- a/content/en/methods/page/Eq.md +++ b/content/en/methods/page/Eq.md @@ -9,7 +9,7 @@ action: signatures: [PAGE1.Eq PAGE2] --- -In this contrived example from a single page template, we list all pages in the current section except for the current page. +In this contrived example from a single template, we list all pages in the current section except for the current page. ```go-html-template {{ $currentPage := . }} diff --git a/content/en/methods/page/GetPage.md b/content/en/methods/page/GetPage.md index 9b4ced345b..3d8a9a89bb 100644 --- a/content/en/methods/page/GetPage.md +++ b/content/en/methods/page/GetPage.md @@ -36,9 +36,9 @@ content/ └── _index.md ``` -The examples below depict the result of rendering works/paintings/the-mona-lisa.md with a single page template: +The examples below depict the result of rendering works/paintings/the-mona-lisa.md: -```go-html-template +{{< code file=layouts/works/single.html >}} {{ with .GetPage "starry-night" }} {{ .Title }} → Starry Night {{ end }} @@ -62,4 +62,4 @@ The examples below depict the result of rendering works/paintings/the-mona-lisa. {{ with .GetPage "/works/sculptures/david" }} {{ .Title }} → David {{ end }} -``` +{{< /code >}} diff --git a/content/en/methods/page/HasMenuCurrent.md b/content/en/methods/page/HasMenuCurrent.md index 68b645905e..a092f22c03 100644 --- a/content/en/methods/page/HasMenuCurrent.md +++ b/content/en/methods/page/HasMenuCurrent.md @@ -1,6 +1,6 @@ --- title: HasMenuCurrent -description: Reports whether the given page object matches the page object associated with one of the child menu entries under the given menu entry in the given menu. +description: Reports whether the given Page object matches the Page object associated with one of the child menu entries under the given menu entry in the given menu. categories: [] keywords: [] action: @@ -11,7 +11,7 @@ action: aliases: [/functions/hasmenucurrent] --- -If the page object associated with the menu entry is a section, this method also returns `true` for any descendant of that section. +If the `Page` object associated with the menu entry is a section, this method also returns `true` for any descendant of that section. ```go-html-template {{ $currentPage := . }} @@ -28,4 +28,4 @@ If the page object associated with the menu entry is a section, this method also See [menu templates] for a complete example. -[menu templates]: /templates/menu-templates/#example +[menu templates]: /templates/menu/#example diff --git a/content/en/methods/page/InSection.md b/content/en/methods/page/InSection.md index 41ce918f38..b3124b3f50 100644 --- a/content/en/methods/page/InSection.md +++ b/content/en/methods/page/InSection.md @@ -17,7 +17,7 @@ action: toc: true --- -The `InSection` method on a page object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling. +The `InSection` method on a `Page` object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling. {{% include "methods/page/_common/definition-of-section.md" %}} diff --git a/content/en/methods/page/IsMenuCurrent.md b/content/en/methods/page/IsMenuCurrent.md index 61283fd8ba..8a939b1a12 100644 --- a/content/en/methods/page/IsMenuCurrent.md +++ b/content/en/methods/page/IsMenuCurrent.md @@ -1,6 +1,6 @@ --- title: IsMenuCurrent -description: Reports whether the given page object matches the page object associated with the given menu entry in the given menu. +description: Reports whether the given Page object matches the Page object associated with the given menu entry in the given menu. categories: [] keywords: [] action: @@ -26,4 +26,4 @@ aliases: [/functions/ismenucurrent] See [menu templates] for a complete example. -[menu templates]: /templates/menu-templates/#example +[menu templates]: /templates/menu/#example diff --git a/content/en/methods/page/Paginate.md b/content/en/methods/page/Paginate.md index ce0087f318..d9acb6b933 100644 --- a/content/en/methods/page/Paginate.md +++ b/content/en/methods/page/Paginate.md @@ -22,7 +22,12 @@ There is also a `Paginator` method on `Page` objects, but it can neither filter The `Paginate` method is more flexible. {{% /note %}} -You can invoke pagination on `home`, `section`, `taxonomy`, and `term` pages. +You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. + +[home template]: /templates/types/#home +[section templates]: /templates/types/#section +[taxonomy templates]: /templates/types/#taxonomy +[term templates]: /templates/types/#term {{< code file=layouts/_default/list.html >}} {{ $pages := where .Site.RegularPages "Section" "articles" }} @@ -44,6 +49,3 @@ In the example above, we: {{% note %}} Please note that the results of pagination are cached. Once you have invoked either the `Paginator` or `Paginate` method, the paginated collection is immutable. Additional invocations of these methods will have no effect. {{% /note %}} - -[context]: /getting-started/glossary/#context -[pagination]: /templates/pagination/ diff --git a/content/en/methods/page/Paginator.md b/content/en/methods/page/Paginator.md index 3fae6e83b4..f57e2437ea 100644 --- a/content/en/methods/page/Paginator.md +++ b/content/en/methods/page/Paginator.md @@ -16,7 +16,13 @@ The number of elements on each pager is determined by your [site configuration]. [site configuration]: /getting-started/configuration/#pagination -You can invoke pagination on `home`, `section`, `taxonomy`, and `term` pages. Each of these receive a collection of regular pages in [context]. When you invoke the `Paginator` method, it paginates the page collection received in context. +You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. Each of these receives a collection of regular pages in [context]. When you invoke the `Paginator` method, it paginates the page collection received in context. + +[home template]: /templates/types/#home +[section templates]: /templates/types/#section +[taxonomy templates]: /templates/types/#taxonomy +[term templates]: /templates/types/#term +[context]: /getting-started/glossary/#context {{< code file=layouts/_default/list.html >}} {{ range .Paginator.Pages }} @@ -38,6 +44,3 @@ The [`Paginate`] method is more flexible, and strongly recommended. {{% note %}} Please note that the results of pagination are cached. Once you have invoked either the `Paginator` or `Paginate` method, the paginated collection is immutable. Additional invocations of these methods will have no effect. {{% /note %}} - -[context]: /getting-started/glossary/#context -[pagination]: /templates/pagination/ diff --git a/content/en/methods/page/Render.md b/content/en/methods/page/Render.md index 9a70d2bedc..66aa6be7b8 100644 --- a/content/en/methods/page/Render.md +++ b/content/en/methods/page/Render.md @@ -70,6 +70,6 @@ layouts/_default/li.html See [content views] for more examples. -[content views]: /templates/views/ +[content views]: /templates/content-view/ [`partial`]: /functions/partials/include/ [content type]: /getting-started/glossary/#content-type diff --git a/content/en/methods/page/Sitemap.md b/content/en/methods/page/Sitemap.md index d6159267dc..3277520fbd 100644 --- a/content/en/methods/page/Sitemap.md +++ b/content/en/methods/page/Sitemap.md @@ -74,4 +74,4 @@ And this simplistic sitemap template: The change frequency will be `hourly` for the news page, and `monthly` for other pages. -[sitemap templates]: /templates/sitemap-template/ +[sitemap templates]: /templates/sitemap/ diff --git a/content/en/methods/page/_index.md b/content/en/methods/page/_index.md index 278541c5ab..6dfaad9ae7 100644 --- a/content/en/methods/page/_index.md +++ b/content/en/methods/page/_index.md @@ -7,6 +7,7 @@ keywords: [] menu: docs: parent: methods +aliases: [/variables/page/] --- Use these methods with a Page object. diff --git a/content/en/methods/site/GetPage.md b/content/en/methods/site/GetPage.md index 3505e582ab..2a972e2af9 100644 --- a/content/en/methods/site/GetPage.md +++ b/content/en/methods/site/GetPage.md @@ -36,7 +36,7 @@ content/ └── _index.md ``` -This home page template: +This home template: ```go-html-template {{ with .Site.GetPage "/works/paintings" }} @@ -96,7 +96,7 @@ content/ └── _index.md ``` -In the home page template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle]: +In the home template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle]: ```go-html-template {{ with .Site.GetPage "/headless" }} diff --git a/content/en/methods/site/MainSections.md b/content/en/methods/site/MainSections.md index 251fe1a977..aa6e84bda5 100644 --- a/content/en/methods/site/MainSections.md +++ b/content/en/methods/site/MainSections.md @@ -46,7 +46,7 @@ Template: When creating a theme, instead of hardcoding section names when listing the most relevant pages on the front page, instruct site authors to set `params.mainSections` in their site configuration. -Then your home page template can do something like this: +Then your home template can do something like this: ```go-html-template {{ range where .Site.RegularPages "Section" "in" .Site.MainSections }} diff --git a/content/en/methods/site/Menus.md b/content/en/methods/site/Menus.md index 98ce4e879d..e51980c2e2 100644 --- a/content/en/methods/site/Menus.md +++ b/content/en/methods/site/Menus.md @@ -88,7 +88,7 @@ You will typically render a menu using a partial template. As the active menu en The example above is simplistic. Please see the [menu templates] section for more information. -[menu templates]: /templates/menu-templates/ +[menu templates]: /templates/menu/ [`partial`]: /functions/partials/include/ [`partialCached`]: /functions/partials/includecached/ diff --git a/content/en/methods/site/Taxonomies.md b/content/en/methods/site/Taxonomies.md index 219fe188b1..d23a0908f2 100644 --- a/content/en/methods/site/Taxonomies.md +++ b/content/en/methods/site/Taxonomies.md @@ -1,6 +1,6 @@ --- title: Taxonomies -description: Returns a data structure containing the site's taxonomy objects, the terms within each taxonomy object, and the pages to which the terms are assigned. +description: Returns a data structure containing the site's Taxonomy objects, the terms within each Taxonomy object, and the pages to which the terms are assigned. categories: [] keywords: [] action: @@ -9,6 +9,13 @@ action: signatures: [SITE.Taxonomies] --- + + Conceptually, the `Taxonomies` method on a `Site` object returns a data structure such as: {{< code-toggle >}} @@ -97,3 +104,82 @@ Please see the [taxonomies] section for a complete explanation and examples. [taxonomies]: /content-management/taxonomies/ {{% /note %}} + +## Examples + +### List content with the same taxonomy term + +If you are using a taxonomy for something like a series of posts, you can list individual pages associated with the same term. For example: + +```go-html-template + +``` + +### List 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. + +```go-html-template + +``` + +### Render a site's taxonomies + +The following example displays all terms in a site's tags taxonomy: + +```go-html-template + +``` +This example will list all taxonomies and their terms, as well as all the content assigned to each of the terms. + +{{< code file=layouts/partials/all-taxonomies.html >}} +{{ with .Site.Taxonomies }} + {{ $numberOfTerms := 0 }} + {{ range $taxonomy, $terms := . }} + {{ $numberOfTerms = len . | add $numberOfTerms }} + {{ end }} + + {{ if gt $numberOfTerms 0 }} + + {{ end }} +{{ end }} +{{< /code >}} diff --git a/content/en/methods/site/_index.md b/content/en/methods/site/_index.md index 39f66f308b..bf322ee074 100644 --- a/content/en/methods/site/_index.md +++ b/content/en/methods/site/_index.md @@ -7,6 +7,7 @@ keywords: [] menu: docs: parent: methods +aliases: [/variables/site/] --- Use these methods with Site objects. A multilingual project will have two or more sites, one for each language. diff --git a/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md b/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md index 6bf86cd85a..ef78c8eaeb 100644 --- a/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md +++ b/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md @@ -4,7 +4,7 @@ Before we can use a `Taxonomy` method, we need to capture a `Taxonomy` object. -## Capture a taxonomy object +## Capture a Taxonomy object Consider this site configuration: @@ -26,13 +26,13 @@ content/ └── _index.md ``` -To capture the "genres" taxonomy object from within any template, use the [`Taxonomies`] method on a `Site` object. +To capture the "genres" `Taxonomy` object from within any template, use the [`Taxonomies`] method on a `Site` object. ```go-html-template {{ $taxonomyObject := .Site.Taxonomies.genres }} ``` -To capture the "genres" taxonomy object when rendering its page with a taxonomy template, use the [`Terms`] method on the page's [`Data`] object: +To capture the "genres" `Taxonomy` object when rendering its page with a taxonomy template, use the [`Terms`] method on the page's [`Data`] object: {{< code file=layouts/_default/taxonomy.html >}} {{ $taxonomyObject := .Data.Terms }} diff --git a/content/en/quick-reference/page-collections.md b/content/en/quick-reference/page-collections.md index eca65a93e0..8ad9407e31 100644 --- a/content/en/quick-reference/page-collections.md +++ b/content/en/quick-reference/page-collections.md @@ -35,6 +35,19 @@ Use the [`where`] function to filter page collections. ## Sort +By default, Hugo sorts page collections by: + +1. [Weight] +2. [Date] in descending order +3. [LinkTitle] falling back to [Title] +4. [Filename] if the page is backed by a file + +[Date]: /methods/page/date/ +[Weight]: /methods/page/weight/ +[LinkTitle]: /methods/page/linktitle/ +[Title]: /methods/page/title/ +[Filename]: /methods/page/file/#filename + Use these methods to sort page collections. {{< list-pages-in-section path=/methods/pages filter=methods_pages_sort filterType=include titlePrefix=. omitElementIDs=true titlePrefix=PAGES. >}} diff --git a/content/en/templates/404.md b/content/en/templates/404.md index 44858f8b15..43c2405fc1 100644 --- a/content/en/templates/404.md +++ b/content/en/templates/404.md @@ -1,14 +1,14 @@ --- title: Custom 404 page -linkTitle: 404 template +linkTitle: 404 templates description: Create a template to render a 404 error page. categories: [templates] -keywords: ['404',page not found] +keywords: [] menu: docs: parent: templates - weight: 220 -weight: 220 + weight: 160 +weight: 160 --- To render a 404 error page in the root of your site, create a 404 template in the root of the layouts directory. For example: diff --git a/content/en/templates/_common/_index.md b/content/en/templates/_common/_index.md new file mode 100644 index 0000000000..4328d4d145 --- /dev/null +++ b/content/en/templates/_common/_index.md @@ -0,0 +1,13 @@ +--- +cascade: + _build: + list: never + publishResources: false + render: never +--- + + diff --git a/content/en/templates/_common/filter-sort-group.md b/content/en/templates/_common/filter-sort-group.md new file mode 100644 index 0000000000..89cc095f5f --- /dev/null +++ b/content/en/templates/_common/filter-sort-group.md @@ -0,0 +1,9 @@ +--- +# Do not remove front matter. +--- + +{{% note %}} +The [page collections quick reference guide] describes methods and functions to filter, sort, and group page collections. + +[page collections quick reference guide]: /quick-reference/page-collections/ +{{% /note %}} diff --git a/content/en/templates/base.md b/content/en/templates/base.md index 6262e74b87..45320e3cfd 100644 --- a/content/en/templates/base.md +++ b/content/en/templates/base.md @@ -1,13 +1,13 @@ --- -title: Base templates and blocks -description: The base and block constructs allow you to define the outer shell of your master templates (i.e., the chrome of the page). +title: Base templates +description: The base and block construct allows you to define the outer shell of your master templates (i.e., the chrome of the page). categories: [templates,fundamentals] -keywords: [blocks,base] +keywords: [] menu: docs: parent: templates - weight: 40 -weight: 40 + weight: 50 +weight: 50 toc: true aliases: [/templates/blocks/,/templates/base-templates-and-blocks/] --- @@ -50,7 +50,7 @@ The following defines a simple base template at `_default/baseof.html`. As a def ## Override the base template -From the above base template, you can define a [default list template][hugolists]. The default list template will inherit all of the code defined above and can then implement its own `"main"` block from: +The default list template will inherit all of the code defined above and can then implement its own `"main"` block from: {{< code file=layouts/_default/list.html >}} {{ define "main" }} @@ -78,7 +78,7 @@ Code that you put outside the block definitions *can* break your layout. This ev [See this thread from the Hugo discussion forums.](https://discourse.gohugo.io/t/baseof-html-block-templates-and-list-types-results-in-empty-pages/5612/6) {{% /note %}} -The following shows how you can override both the `"main"` and `"title"` block areas from the base template with code unique to your [default single page template][singletemplate]: +The following shows how you can override both the `"main"` and `"title"` block areas from the base template with code unique to your default [single template]: {{< code file=layouts/_default/single.html >}} {{ define "title" }} @@ -91,7 +91,4 @@ The following shows how you can override both the `"main"` and `"title"` block a {{ end }} {{< /code >}} -[hugolists]: /templates/lists/ -[lookup]: /templates/lookup-order/ -[rendering the section]: /templates/section-templates/ -[singletemplate]: /templates/single-page-templates/ +[single template]: /templates/types/#single diff --git a/content/en/templates/views.md b/content/en/templates/content-view.md similarity index 58% rename from content/en/templates/views.md rename to content/en/templates/content-view.md index 4170196b6e..80ac4ea879 100644 --- a/content/en/templates/views.md +++ b/content/en/templates/content-view.md @@ -2,25 +2,24 @@ title: Content view templates description: Hugo can render alternative views of your content, useful in list and summary views. categories: [templates] -keywords: [views] +keywords: [] menu: docs: parent: templates - weight: 110 -weight: 110 + weight: 120 +weight: 120 toc: true +aliases: [/templates/views/] --- -These alternative **content views** are especially useful in [list templates][lists]. - The following are common use cases for content views: -* You want content of every type to be shown on the homepage but only with limited [summary views][summaries]. -* You only want a bulleted list of your content on a [taxonomy list page][taxonomylists]. Views make this very straightforward by delegating the rendering of each different type of content to the content itself. +* You want content of every type to be shown on the home page but only with limited [summary views][summaries]. +* You only want a bulleted list of your content in a [taxonomy template]. Views make this very straightforward by delegating the rendering of each different type of content to the content itself. ## Create a content view -To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `posts` and `project` content types. As you can see, these sit next to the [single content view][single] template, `single.html`. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view. +To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `posts` and `project` content types. As you can see, these sit next to the [single template], `single.html`. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view. ```txt ▾ layouts/ @@ -30,33 +29,23 @@ To create a new view, create a template in each of your different content type d summary.html ▾ project/ li.html - single.html - summary.html -``` - -Hugo also has support for a default content view template to be used in the event that a specific content view template has not been provided for that type. Content views can also be defined in the `_default` directory and will work the same as list and single templates who eventually trickle down to the `_default` directory as a matter of the lookup order. - -```txt -▾ layouts/ - ▾ _default/ - li.html - single.html + single.htm] summary.html ``` ## Which template will be rendered? -The following is the [lookup order] for content views: +The following is the lookup order for content views ordered by specificity. 1. `/layouts//.html` -2. `/layouts/_default/.html` -3. `/themes//layouts//.html` -4. `/themes//layouts/_default/.html` +1. `/layouts/
/.html` +1. `/layouts/_default/.html` +1. `/themes//layouts//.html` +1. `/themes//layouts/
/.html` +1. `/themes//layouts/_default/.html` ## Example: content view inside a list -The following example demonstrates how to use content views inside your [list templates][lists]. - ### `list.html` In this example, `.Render` is passed into the template to call the [render function][render]. `.Render` is a special function that instructs content to render itself with the view template provided as the first argument. In this case, the template is going to render the `summary.html` view that follows: @@ -74,7 +63,7 @@ In this example, `.Render` is passed into the template to call the [render funct ### `summary.html` -Hugo passes the page object to the following `summary.html` view template. +Hugo passes the `Page` object to the following `summary.html` view template. {{< code file=layouts/_default/summary.html >}}
@@ -100,8 +89,7 @@ Continuing on the previous example, we can change our render function to use a s {{< /code >}} -[lists]: /templates/lists/ [render]: /methods/page/render/ -[single]: /templates/single-page-templates/ +[single template]: /templates/types/#single [summaries]: /content-management/summaries/ -[taxonomylists]: /templates/taxonomy-templates/ +[taxonomy template]: /templates/types/#taxonomy diff --git a/content/en/templates/embedded.md b/content/en/templates/embedded.md index 5b2043962d..5fbbb8d963 100644 --- a/content/en/templates/embedded.md +++ b/content/en/templates/embedded.md @@ -2,12 +2,12 @@ title: Embedded templates description: Hugo provides embedded templates for common use cases. categories: [templates] -keywords: [internal, analytics,] +keywords: [] menu: docs: parent: templates - weight: 190 -weight: 190 + weight: 200 +weight: 200 toc: true aliases: [/templates/internal] --- diff --git a/content/en/templates/home.md b/content/en/templates/home.md new file mode 100644 index 0000000000..3086791c5c --- /dev/null +++ b/content/en/templates/home.md @@ -0,0 +1,55 @@ +--- +title: Home templates +description: The home page of a website is often formatted differently than the other pages. For this reason, Hugo makes it easy for you to define your new site's home page as a unique template. +categories: [templates] +keywords: [] +menu: + docs: + parent: templates + weight: 60 +weight: 60 +toc: true +aliases: [/layout/homepage/,/templates/homepage-template/,/templates/homepage/] +--- + +The home template is the *only* required template for building a site and therefore useful when bootstrapping a new site and template. It is also the only required template if you are developing a single-page website. + + +{{< youtube ut1xtRZ1QOA >}} + +## Home template lookup order + +See [Template Lookup](/templates/lookup-order/). + +## Add content and front matter to the home page + +The home page accepts content and front matter from an `_index.md` file. This file should live at the root of your `content` folder (i.e., `content/_index.md`). You can then add body copy and metadata to your home page the way you would any other content file. + +See the home template below or [Content Organization][contentorg] for more information on the role of `_index.md` in adding content and front matter to list pages. + +## Example home template + +{{< code file=layouts/_default/home.html >}} +{{ define "main" }} +
+
+

{{ .Title }}

+ {{ with .Params.subtitle }} + {{ . }} + {{ end }} +
+
+ + {{ .Content }} +
+
+ {{ range first 10 .Site.RegularPages }} + {{ .Render "summary" }} + {{ end }} +
+
+{{ end }} +{{< /code >}} + +[contentorg]: /content-management/organization/ +[lookup]: /templates/lookup-order/ diff --git a/content/en/templates/homepage.md b/content/en/templates/homepage.md deleted file mode 100644 index cd5b32604e..0000000000 --- a/content/en/templates/homepage.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: Homepage template -description: The homepage of a website is often formatted differently than the other pages. For this reason, Hugo makes it easy for you to define your new site's homepage as a unique template. -categories: [templates] -keywords: [homepage] -menu: - docs: - parent: templates - weight: 70 -weight: 70 -toc: true -aliases: [/layout/homepage/,/templates/homepage-template/] ---- - -The homepage template is the *only* required template for building a site and therefore useful when bootstrapping a new site and template. It is also the only required template if you are developing a single-page website. - - -{{< youtube ut1xtRZ1QOA >}} - -## Homepage template lookup order - -See [Template Lookup](/templates/lookup-order/). - -## Add content and front matter to the homepage - -The homepage, similar to other [list pages in Hugo][lists], accepts content and front matter from an `_index.md` file. This file should live at the root of your `content` folder (i.e., `content/_index.md`). You can then add body copy and metadata to your homepage the way you would any other content file. - -See the homepage template below or [Content Organization][contentorg] for more information on the role of `_index.md` in adding content and front matter to list pages. - -## Example homepage template - -{{< code file=layouts/index.html >}} -{{ define "main" }} -
-
-

{{ .Title }}

- {{ with .Params.subtitle }} - {{ . }} - {{ end }} -
-
- - {{ .Content }} -
-
- {{ range first 10 .Site.RegularPages }} - {{ .Render "summary" }} - {{ end }} -
-
-{{ end }} -{{< /code >}} - -[contentorg]: /content-management/organization/ -[lists]: /templates/lists/ -[lookup]: /templates/lookup-order/ diff --git a/content/en/templates/introduction.md b/content/en/templates/introduction.md index 994e818540..bb87027173 100644 --- a/content/en/templates/introduction.md +++ b/content/en/templates/introduction.md @@ -403,7 +403,7 @@ Use the [`template`] function to include one or more of Hugo's [embedded templat Use the [`partial`] or [`partialCached`] function to include one or more [partial templates]: -[partial templates]: /templates/partials +[partial templates]: /templates/partial ```go-html-template {{ partial "breadcrumbs.html" . }} diff --git a/content/en/templates/lists/index.md b/content/en/templates/lists/index.md deleted file mode 100644 index e9b1dc56b8..0000000000 --- a/content/en/templates/lists/index.md +++ /dev/null @@ -1,240 +0,0 @@ ---- -title: Lists of content in Hugo -linkTitle: List templates -description: Lists have a specific meaning and usage in Hugo when it comes to rendering your site homepage, section page, taxonomy list, or taxonomy terms list. -categories: [templates] -keywords: [lists,sections,rss,taxonomies,terms] -menu: - docs: - parent: templates - weight: 60 -weight: 60 -toc: true -aliases: [/templates/list/,/layout/indexes/] ---- - -## What is a list page template? - -{{< youtube 8b2YTSMdMps >}} - -A list page template is a template used to render multiple pieces of content in a single HTML page. The exception to this rule is the homepage, which is still a list but has its own [dedicated template][homepage]. - -Hugo uses the term *list* in its truest sense; i.e. a sequential arrangement of material, especially in alphabetical or numerical order. Hugo uses list templates on any output HTML page where content is traditionally listed: - -* [Home page](/templates/homepage) -* [Section pages](/templates/section-templates) -* [Taxonomy pages](/templates/taxonomy-templates) -* [Taxonomy term pages](/templates/taxonomy-templates) -* [RSS feeds](/templates/rss) -* [Sitemaps](/templates/sitemap-template) - -For template lookup order, see [Template Lookup](/templates/lookup-order/). - -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.](site-hierarchy.svg)](site-hierarchy.svg) - -## Add content and front matter to list pages - -Add content and front matter to list pages by creating an _index.md file for `home`, `section`, `taxonomy`, and `term` pages. - -The following is an example of a typical Hugo project directory's content: - -```txt -. -... -├── content -| ├── posts -| | ├── _index.md -| | ├── post-01.md -| | └── post-02.md -| └── quote -| | ├── quote-01.md -| | └── quote-02.md -... -``` - -Using the above example, let's assume you have the following in `content/posts/_index.md`: - -{{< code file=content/posts/_index.md >}} ---- -title: My Go Journey -date: 2017-03-23 -publishdate: 2017-03-24 ---- - -I decided to start learning Go in March 2017. - -Follow my journey through this new blog. -{{< /code >}} - -You can now access this `_index.md`'s' content in your list template: - -{{< code file=layouts/_default/list.html >}} -{{ define "main" }} -
-
-
-

{{ .Title }}

-
- - {{ .Content }} -
- -
-{{ end }} -{{< /code >}} - -This above will output the following HTML: - -{{< code file=example.com/posts/index.html >}} - -
-
-
-

My Go Journey

-
-

I decided to start learning Go in March 2017.

-

Follow my journey through this new blog.

-
- -
- -{{< /code >}} - -### List pages without `_index.md` - -You do *not* have to create an `_index.md` file for every list page (i.e. section, taxonomy, taxonomy terms, etc) or the homepage. If Hugo does not find an `_index.md` within the respective content section when rendering a list template, the page will be created but with no `{{ .Content }}` and only the default values for `.Title` etc. - -Using this same `layouts/_default/list.html` template and applying it to the `quotes` section above will render the following output. Note that `quotes` does not have an `_index.md` file to pull from: - -{{< code file=example.com/quote/index.html >}} - -
-
-
- -

Quotes

-
-
- -
- -{{< /code >}} - -{{% note %}} -By default, Hugo capitalizes and pluralizes automatic list titles including section, taxonomy, and term pages. You can disable these transformations by setting [`capitalizeListTitles`] and [`pluralizeListTitles`] in your site configuration. - -You can change the capitalization style in your site configuration to one of `ap`, `chicago`, `go`, `firstupper`, or `none`. See [details]. - -[`capitalizeListTitles`]: /getting-started/configuration/#capitalizelisttitles -[`pluralizeListTitles`]: /getting-started/configuration/#pluralizelisttitles -[details]: /getting-started/configuration/#configure-title-case -{{% /note %}} - -## Example list templates - -### Section template - -This list template has been modified slightly from a template originally used in [spf13.com](https://spf13.com/). It makes use of [partial templates][partials] for the chrome of the rendered page rather than using a [base template][base]. The examples that follow also use the [content view templates][views] `li.html` or `summary.html`. - -{{< code file=layouts/section/posts.html >}} -{{ partial "header.html" . }} -{{ partial "subheader.html" . }} -
-
-

{{ .Title }}

-
    - - {{ range .Pages }} - {{ .Render "li" }} - {{ end }} -
-
-
-{{ partial "footer.html" . }} -{{< /code >}} - -### Taxonomy template - -{{< code file=layouts/_default/taxonomy.html >}} -{{ define "main" }} -
-
-

{{ .Title }}

- - {{ range .Pages }} - {{ .Render "summary" }} - {{ end }} -
-
-{{ end }} -{{< /code >}} - -## Sort content - -By default, Hugo sorts page collections by: - -1. Page [weight] -2. Page [date] (descending) -3. Page [linkTitle], falling back to page [title] -4. Page file path if the page is backed by a file - -[date]: /methods/page/date/ -[weight]: /methods/page/weight/ -[linkTitle]: /methods/page/linktitle/ -[title]: /methods/page/title/ - -Change the sort order using any of the methods below. - -{{< list-pages-in-section path=/methods/pages filter=methods_pages_sort filterType=include titlePrefix=. omitElementIDs=true >}} - -## Group content - -Group your content by field, parameter, or date using any of the methods below. - -{{< list-pages-in-section path=/methods/pages filter=methods_pages_group filterType=include titlePrefix=. omitElementIDs=true >}} - -## Filtering and limiting lists - -Sometimes you only want to list a subset of the available content. A -common is to only display posts from [main sections] -on the blog's homepage. - -See the documentation on [`where`] and -[`first`] for further details. - -[base]: /templates/base/ -[bepsays]: https://bepsays.com/en/2016/12/19/hugo-018/ -[directorystructure]: /getting-started/directory-structure/ -[`Format` function]: /methods/time/format/ -[front matter]: /content-management/front-matter/ -[getpage]: /methods/page/getpage/ -[homepage]: /templates/homepage/ -[mentalmodel]: https://webstyleguide.com/wsg3/3-information-architecture/3-site-structure.html -[partials]: /templates/partials/ -[RSS 2.0]: https://cyber.harvard.edu/rss/rss.html -[rss]: /templates/rss/ -[sections]: /content-management/sections/ -[sectiontemps]: /templates/section-templates/ -[taxlists]: /templates/taxonomy-templates/#taxonomy-templates -[taxterms]: /templates/taxonomy-templates/#term-templates -[taxvars]: /methods/taxonomy/ -[views]: /templates/views/ -[`where`]: /functions/collections/where/ -[`first`]: /functions/collections/first/ -[main sections]: /methods/site/mainsections/ -[`time.Format`]: /functions/time/format/ diff --git a/content/en/templates/lookup-order.md b/content/en/templates/lookup-order.md index 406a17c381..3f9a9c527e 100644 --- a/content/en/templates/lookup-order.md +++ b/content/en/templates/lookup-order.md @@ -1,13 +1,14 @@ --- title: Template lookup order +linkTitle: Lookup order description: Hugo uses the rules below to select a template for a given page, starting from the most specific. categories: [templates,fundamentals] -keywords: [templates] +keywords: [] menu: docs: parent: templates - weight: 30 -weight: 30 + weight: 40 +weight: 40 toc: true --- @@ -99,23 +100,29 @@ layouts/ └── single.html <-- renders about.md ``` -## Home page +## Home templates + +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. {{< datatable-filtered "output" "layouts" "Kind == home" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -## Single pages +## Single templates + +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. {{< datatable-filtered "output" "layouts" "Kind == page" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -## Section pages +## Section templates -A section page is a list of pages within a given section. +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. {{< datatable-filtered "output" "layouts" "Kind == section" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -## Taxonomy pages +## Taxonomy templates -A taxonomy page is a list of terms within a given taxonomy. The examples below assume the following site configuration: +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. + +The examples below assume the following site configuration: {{< code-toggle file=hugo >}} [taxonomies] @@ -124,9 +131,11 @@ category = 'categories' {{< datatable-filtered "output" "layouts" "Kind == taxonomy" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -## Term pages +## Term templates + +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. -A term page is a list of pages associated with a given term. The examples below assume the following site configuration: +The examples below assume the following site configuration: {{< code-toggle file=hugo >}} [taxonomies] @@ -134,3 +143,16 @@ category = 'categories' {{< /code-toggle >}} {{< datatable-filtered "output" "layouts" "Kind == term" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} + +## RSS templates + +These template paths are sorted by specificity in descending order. The least specific path is at the bottom of each list. + +The examples below assume the following site configuration: + +{{< code-toggle file=hugo >}} +[taxonomies] +category = 'categories' +{{< /code-toggle >}} + +{{< datatable-filtered "output" "layouts" "OutputFormat == rss" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} diff --git a/content/en/templates/menu-templates.md b/content/en/templates/menu.md similarity index 96% rename from content/en/templates/menu-templates.md rename to content/en/templates/menu.md index 403affe3cb..de103803c3 100644 --- a/content/en/templates/menu-templates.md +++ b/content/en/templates/menu.md @@ -1,15 +1,16 @@ --- -title: Menu templates +title: Menus description: Create templates to render one or more menus. categories: [templates] -keywords: [lists,sections,menus] +keywords: [] menu: docs: + identifier: templates-menu parent: templates - weight: 140 -weight: 140 + weight: 180 +weight: 180 toc: true -aliases: [/templates/menus/] +aliases: [/templates/menus/,/templates/menu-templates/] --- ## Overview diff --git a/content/en/templates/output-formats.md b/content/en/templates/output-formats.md index ee4dbf0b6f..c81d584886 100644 --- a/content/en/templates/output-formats.md +++ b/content/en/templates/output-formats.md @@ -2,7 +2,7 @@ title: Custom output formats description: Hugo can output content in multiple formats, including calendar events, e-book formats, Google AMP, and JSON search indexes, or any custom text format. categories: [templates,fundamentals] -keywords: ["amp", "outputs", "rss"] +keywords: [] menu: docs: parent: templates @@ -79,7 +79,7 @@ isPlainText = true protocol = "bep://" {{}} -The above example is fictional, but if used for the homepage on a site with `baseURL` `https://example.org`, it will produce a plain text homepage with the URL `bep://example.org/myindex.enr`. +The above example is fictional, but if used for the home page on a site with `baseURL` `https://example.org`, it will produce a plain text home page with the URL `bep://example.org/myindex.enr`. ### Configure output formats @@ -163,7 +163,7 @@ Example from site configuration file: Note that in the above examples, the _output formats_ for `section`, `taxonomy` and `term` will stay at their default value `['html','rss']`. -* The `outputs` definition is per page [`Kind`][page_kinds]. +* The `outputs` definition is per page [`Kind`]. * The names (e.g. `html`, `amp`) must match the `name` of a defined output format, and can be overridden per page in front matter. The following is an example of front matter in a content file that defines output formats for the rendered `Page`: @@ -242,9 +242,7 @@ The partial below is a plain text template . The output format is `csv`, and sin {{ partial "mytextpartial.csv" . }} ``` -[base]: /templates/base/ [site configuration]: /getting-started/configuration/ [lookup order]: /templates/lookup-order/ [media type]: https://en.wikipedia.org/wiki/Media_type -[partials]: /templates/partials/ [`kind`]: /methods/page/kind/ diff --git a/content/en/templates/pagination.md b/content/en/templates/pagination.md index b93ef26a6b..2fb3382782 100644 --- a/content/en/templates/pagination.md +++ b/content/en/templates/pagination.md @@ -6,8 +6,8 @@ keywords: [] menu: docs: parent: templates - weight: 180 -weight: 180 + weight: 190 +weight: 190 toc: true aliases: [/extras/pagination,/doc/pagination/] --- @@ -27,7 +27,7 @@ The most common templating mistake related to pagination is invoking pagination ## Terminology paginate -: To split a list page into two or more subsets. +: To split a [list page] into two or more subsets. pagination : The process of paginating a list page. @@ -38,6 +38,8 @@ pager paginator : A collection of pagers. +[list page]: /getting-started/glossary/#list-page + ## Configuration Control pagination behavior in your site configuration. These are the default settings: @@ -150,7 +152,9 @@ When paginating conditionally, do not use the `compare.Conditional` function due ## Grouping -Use pagination with any of the grouping methods. For example: +Use pagination with any of the [grouping methods]. For example: + +[grouping methods]: /quick-reference/page-collections/#group ```go-html-template {{ $pages := where site.RegularPages "Type" "posts" }} diff --git a/content/en/templates/partials.md b/content/en/templates/partial.md similarity index 87% rename from content/en/templates/partials.md rename to content/en/templates/partial.md index 34d0a9ddaa..30055e7e3a 100644 --- a/content/en/templates/partials.md +++ b/content/en/templates/partial.md @@ -2,27 +2,18 @@ title: Partial templates description: Partials are smaller, context-aware components in your list and page templates that can be used economically to keep your templating DRY. categories: [templates] -keywords: [lists,sections,partials] +keywords: [] menu: docs: parent: templates - weight: 120 -weight: 120 + weight: 110 +weight: 110 toc: true -aliases: [/templates/partial/,/layout/chrome/,/extras/analytics/] +aliases: [/templates/partials/,/layout/chrome/] --- {{< youtube pjS4pOLyB7c >}} -## Partial template lookup order - -Partial templates---like [single page templates][singletemps] and [list page templates][listtemps]---have a specific [lookup order]. However, partials are simpler in that Hugo will only check in two places: - -1. `layouts/partials/.html` -2. `themes//layouts/partials/.html` - -This allows a theme's end user to copy a partial's contents into a file of the same name for [further customization][customize]. - ## Use partials in your templates All partials for your Hugo project are located in a single `layouts/partials` directory. For better organization, you can create multiple subdirectories within `partials` as well: @@ -50,7 +41,7 @@ All partials are called within your templates using the following pattern: ``` {{% note %}} -One of the most common mistakes with new Hugo users is failing to pass a context to the partial call. In the pattern above, note how "the dot" (`.`) is required as the second argument to give the partial context. You can read more about "the dot" in the [Hugo templating introduction](/templates/introduction/). +One of the most common mistakes with new Hugo users is failing to pass a context to the partial call. In the pattern above, note how "the dot" (`.`) is required as the second argument to give the partial context. You can read more about "the dot" in the [Hugo templating introduction](/templates/introduction/#context). {{% /note %}} {{% note %}} @@ -175,8 +166,6 @@ The following `footer.html` partial template is used for [spf13.com](https://spf [context]: /templates/introduction/ [customize]: /hugo-modules/theme-components/ -[listtemps]: /templates/lists/ [lookup order]: /templates/lookup-order/ [partialcached]: /functions/partials/includecached/ -[singletemps]: /templates/single-page-templates/ [themes]: /themes/ diff --git a/content/en/templates/robots.md b/content/en/templates/robots.md index 63edb1ca86..ee07557949 100644 --- a/content/en/templates/robots.md +++ b/content/en/templates/robots.md @@ -1,14 +1,14 @@ --- -title: Robots.txt file -linkTitle: Robots.txt +title: robots.txt template +linkTitle: robots.txt templates description: Hugo can generate a customized robots.txt in the same way as any other template. categories: [templates] -keywords: [robots,search engines] +keywords: [] menu: docs: parent: templates - weight: 230 -weight: 230 + weight: 170 +weight: 170 aliases: [/extras/robots-txt/] --- diff --git a/content/en/templates/rss.md b/content/en/templates/rss.md index 635a624991..0967bb338c 100644 --- a/content/en/templates/rss.md +++ b/content/en/templates/rss.md @@ -2,12 +2,12 @@ title: RSS templates description: Use the embedded RSS template, or create your own. categories: [templates] -keywords: [rss,xml,templates] +keywords: [] menu: docs: parent: templates - weight: 160 -weight: 160 + weight: 150 +weight: 150 toc: true --- @@ -70,7 +70,7 @@ Hugo will render this to: Override Hugo's [embedded RSS template] by creating one or more of your own, following the naming conventions as shown in the [template lookup order]. [embedded RSS template]: {{% eturl rss %}} -[template lookup order]: #template-lookup-order +[template lookup order]: /templates/lookup-order/#rss-templates For example, to use different templates for home, section, taxonomy, and term pages: @@ -84,9 +84,3 @@ layouts/ ``` RSS templates receive the `.Page` and `.Site` objects in context. - -## Template lookup order - -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`). - -{{< datatable-filtered "output" "layouts" "OutputFormat == rss" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} diff --git a/content/en/templates/section-templates.md b/content/en/templates/section.md similarity index 82% rename from content/en/templates/section-templates.md rename to content/en/templates/section.md index af4c8484e2..28d9315343 100644 --- a/content/en/templates/section-templates.md +++ b/content/en/templates/section.md @@ -1,21 +1,20 @@ --- -title: Section page templates -linkTitle: Section templates +title: Section templates description: Use section templates to list members of a section. categories: [templates] -keywords: [lists,sections,templates] +keywords: [] menu: docs: parent: templates weight: 80 weight: 80 toc: true -aliases: [/templates/sections/] +aliases: [/templates/sections/,/templates/section-templates/] --- ## Add content and front matter to section templates -To effectively leverage section page templates, you should first understand Hugo's [content organization](/content-management/organization/) and, specifically, the purpose of `_index.md` for adding content and front matter to section and other list pages. +To effectively leverage section templates, you should first understand Hugo's [content organization](/content-management/organization/) and, specifically, the purpose of `_index.md` for adding content and front matter to section and other list pages. ## Section template lookup order @@ -82,8 +81,6 @@ Which then returns the following: ``` [contentorg]: /content-management/organization/ -[getpage]: /methods/page/getpage/ -[lists]: /templates/lists/ [lookup]: /templates/lookup-order/ [`where`]: /functions/collections/where/ [sections]: /content-management/sections/ diff --git a/content/en/templates/shortcode-templates.md b/content/en/templates/shortcode.md similarity index 99% rename from content/en/templates/shortcode-templates.md rename to content/en/templates/shortcode.md index dc8e615439..6d9234f71d 100644 --- a/content/en/templates/shortcode-templates.md +++ b/content/en/templates/shortcode.md @@ -3,13 +3,13 @@ title: Create your own shortcodes linkTitle: Shortcode templates description: You can extend Hugo's embedded shortcodes by creating your own using the same templating syntax as that for single and list pages. categories: [templates] -keywords: [shortcodes,templates] +keywords: [] menu: docs: parent: templates weight: 130 weight: 130 -aliases: [/functions/get] +aliases: [/templates/shortcode-templates/] toc: true --- diff --git a/content/en/templates/single-page-templates.md b/content/en/templates/single-page-templates.md deleted file mode 100644 index 9546486f88..0000000000 --- a/content/en/templates/single-page-templates.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Single page templates -description: The primary view of content in Hugo is the single view. Hugo will render every Markdown file provided with a corresponding single template. -categories: [templates] -keywords: [page, templates] -menu: - docs: - parent: templates - weight: 50 -weight: 50 -toc: true -aliases: [/layout/content/] ---- - -## Single page template lookup order - -See [Template Lookup](/templates/lookup-order/). - -## Example single page templates - -{{< code file=layouts/posts/single.html >}} -{{ define "main" }} -
-

{{ .Title }}

-
-
- {{ .Content }} -
-
-
- -{{ end }} -{{< /code >}} - -To easily generate new instances of a content type (e.g., new `.md` files in a section like `project/`) with preconfigured front matter, use [content archetypes][archetypes]. - -[archetypes]: /content-management/archetypes/ -[base templates]: /templates/base/ -[content type]: /content-management/types/ -[directory structure]: /getting-started/directory-structure/ -[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself -[`.format` function]: /methods/time/format/ -[front matter]: /content-management/front-matter/ -[pagetaxonomy]: /templates/taxonomy-templates/#list-terms-assigned-to-a-page -[partials]: /templates/partials/ -[section]: /content-management/sections/ -[spf13]: https://spf13.com/ -[`with`]: /functions/go-template/with/ diff --git a/content/en/templates/single.md b/content/en/templates/single.md new file mode 100644 index 0000000000..f6292ca03f --- /dev/null +++ b/content/en/templates/single.md @@ -0,0 +1,56 @@ +--- +title: Single templates +description: Create a single template to render a single page. +categories: [templates] +keywords: [] +menu: + docs: + parent: templates + weight: 70 +weight: 70 +toc: true +aliases: [/layout/content/,/templates/single-page-templates/] +--- + +The single template below inherits the site's shell from the [base template]. + +[base template]: /templates/types/ + +{{< code file=layouts/_default/single.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} +{{ end }} +{{< /code >}} + +Review the [template lookup order] to select a template path that provides the desired level of specificity. + +[template lookup order]: /templates/lookup-order/#single-templates + +The single template below inherits the site's shell from the base template, and renders the page title, creation date, content, and a list of associated terms in the "tags" taxonomy. + +{{< code file=layouts/_default/single.html >}} +{{ define "main" }} +
+

{{ .Title }}

+ {{ with .Date }} + {{ $dateMachine := . | time.Format "2006-01-02T15:04:05-07:00" }} + {{ $dateHuman := . | time.Format ":date_long" }} + + {{ end }} +
+ {{ .Content }} +
+ +
+{{ end }} +{{< /code >}} diff --git a/content/en/templates/sitemap-template.md b/content/en/templates/sitemap.md similarity index 96% rename from content/en/templates/sitemap-template.md rename to content/en/templates/sitemap.md index 64609f0b9c..9fc1522105 100644 --- a/content/en/templates/sitemap-template.md +++ b/content/en/templates/sitemap.md @@ -2,14 +2,14 @@ title: Sitemap templates description: Hugo provides built-in sitemap templates. categories: [templates] -keywords: [sitemap,xml,templates] +keywords: [] menu: docs: parent: templates - weight: 170 -weight: 170 + weight: 140 +weight: 140 toc: true -aliases: [/layout/sitemap/,/templates/sitemap/] +aliases: [/layout/sitemap/,/templates/sitemap-template/] --- ## Overview diff --git a/content/en/templates/taxonomy-templates.md b/content/en/templates/taxonomy-templates.md deleted file mode 100644 index e83231a5c2..0000000000 --- a/content/en/templates/taxonomy-templates.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -title: Taxonomy templates -description: Taxonomy templating includes taxonomy list pages, taxonomy terms pages, and using taxonomies in your single page templates. -categories: [templates] -keywords: [taxonomies,metadata,front matter,terms,templates] -menu: - docs: - parent: templates - weight: 90 -weight: 90 -toc: true -aliases: [/taxonomies/displaying/,/templates/terms/,/indexes/displaying/,/taxonomies/templates/,/indexes/ordering/, /templates/taxonomies/, /templates/taxonomy/] ---- - -Hugo includes support for user-defined groupings of content called **taxonomies**. Taxonomies are classifications that demonstrate logical relationships between content. See [Taxonomies under Content Management](/content-management/taxonomies) if you are unfamiliar with how Hugo leverages this powerful feature. - -Hugo provides multiple ways to use taxonomies throughout your project templates: - -* Order the way content associated with a taxonomy term is displayed in a [taxonomy template](#taxonomy-templates) -* Order the way the terms for a taxonomy are displayed in a [term template](#term-templates) -* List a single content's taxonomy terms within a [single page template] - -## Taxonomy templates - -Taxonomy list page templates are lists and therefore have all the methods available to [list pages][lists]. - -### Taxonomy template lookup order - -See [Template Lookup](/templates/lookup-order/). - -## Term templates - -### Term template lookup order - -See [Template Lookup](/templates/lookup-order/). - -### Taxonomy methods - -{{< list-pages-in-section path=/methods/taxonomy/ >}} - - -### OrderedTaxonomy - -Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order. - -```go -[]struct { - Name string - WeightedPages WeightedPages -} -``` - -Each element of the slice has: - -.Term -: The Term used. - -.WeightedPages -: A slice of Weighted Pages. - -.Count -: The number of pieces of content assigned to this term. - -.Page -: Returns a page reference for this term. - -.Pages -: All Pages assigned to this term. All [list methods][renderlists] are available to this. - -## WeightedPages - -WeightedPages is simply a slice of WeightedPage. - -```go -type WeightedPages []WeightedPage -``` - -.Count -: The number of pieces of content assigned to this term. - -.Page -: Returns a page reference for this term. - -.Pages -: Returns a slice of pages, which then can be ordered using any of the [list methods][renderlists]. - -## Displaying custom metadata in taxonomy terms templates - -If you need to display custom metadata for each taxonomy term, you will need to create a page for that term at `/content///_index.md` and add your metadata in its front matter, [as explained in the taxonomies documentation](/content-management/taxonomies/#add-custom-metadata-to-a-taxonomy-or-term). Based on the Actors taxonomy example shown there, within your taxonomy terms template, you may access your custom fields by ranging over the page collection returned by the [`Pages`] method: - -```go-html-template -
    - {{ range .Pages }} -
  • - {{ .LinkTitle }} - {{ .Params.wikipedia }} -
  • - {{ end }} -
-``` - -## Order taxonomies - -Taxonomies can be ordered by either alphabetical key or by the number of content pieces assigned to that key. - -### Order alphabetically example - -```go-html-template -
    - {{ range .Data.Terms.Alphabetical }} -
  • {{ .Page.Title }} {{ .Count }}
  • - {{ end }} -
-``` - -## 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. - -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, then the more recent content will be displayed first. - -The default weight for any piece of content is 0. Zero means "does not have a weight", not "has a weight of numerical value zero". - -Weights of zero are thus treated specially: if two pages have unequal weights, and one of them is zero, then the zero-weighted page will always appear after the other one, regardless of the other's weight. Zero weights should thus be used with care: for example, if both positive and negative weights are used to extend a sequence in both directions, a zero-weighted page will appear not in the middle of the list, but at the end. - -### Assign weight - -Content can be assigned weight for each taxonomy that it's assigned to. - -{{< code-toggle file=content/example.md fm=true >}} -tags = [ "a", "b", "c" ] -tags_weight = 22 -categories = ["d"] -title = "Example" -categories_weight = 44 -{{< /code-toggle >}} - -The convention is `taxonomyname_weight`. - -In the above example, this piece of content has a weight of 22 which applies to the sorting when rendering the pages assigned to the "a", "b" and "c" values of the 'tag' taxonomy. - -It has also been assigned the weight of 44 when rendering the 'd' category. - -With this the same piece of content can appear in different positions in different taxonomies. - -Currently taxonomies only support the default ordering of content which is weight -> date. - -There are two different templates that the use of taxonomies will require you to provide. - -Both templates are covered in detail in the templates section. - -A [list template](/templates/lists/) 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 template](/templates/taxonomy-templates/) is a template used to -generate the list of terms for a given template. - -There are four common ways you can display the data in your -taxonomies in addition to the automatic taxonomy pages created by hugo -using the [list templates](/templates/lists/): - -1. For a given piece of content, you can list the terms attached -2. For a given piece of content, you can list other content with the same - term -3. You can list all terms for a taxonomy -4. You can list all taxonomies (with their terms) - -## List terms assigned to a page - -List the terms assigned to a page using the `.Page.GetTerms` method. - -To render an unordered list: - -```go-html-template -{{ $taxonomy := "tags" }} -{{ with .GetTerms $taxonomy }} -

{{ (site.GetPage $taxonomy).LinkTitle }}:

- -{{ end }} -``` - -To render a comma-delimited list: - -```go-html-template -{{ $taxonomy := "tags" }} -{{ with .GetTerms $taxonomy }} -

- {{ (site.GetPage $taxonomy).LinkTitle }}: - {{ range $k, $_ := . -}} - {{ if $k }}, {{ end }} - {{ .LinkTitle }} - {{- end }} -

-{{ end }} -``` - -## List content with the same taxonomy term - -If you are using a taxonomy for something like a series of posts, you can list individual pages associated with the same term. For example: - - - -```go-html-template - -``` - -## List 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. - -```go-html-template - -``` - -## Render a site's taxonomies - -The following example displays all terms in a site's tags taxonomy: - -```go-html-template - -``` -This example will list all taxonomies and their terms, as well as all the content assigned to each of the terms. - -{{< code file=layouts/partials/all-taxonomies.html >}} -{{ with .Site.Taxonomies }} - {{ $numberOfTerms := 0 }} - {{ range $taxonomy, $terms := . }} - {{ $numberOfTerms = len . | add $numberOfTerms }} - {{ end }} - - {{ if gt $numberOfTerms 0 }} - - {{ end }} -{{ end }} -{{< /code >}} - -[`Pages`]: /methods/page/pages/ -[getpage]: /methods/page/getpage/ -[lists]: /templates/lists/ -[renderlists]: /templates/lists/ -[single page template]: /templates/single-page-templates/ diff --git a/content/en/templates/taxonomy.md b/content/en/templates/taxonomy.md new file mode 100644 index 0000000000..d0f24b1b27 --- /dev/null +++ b/content/en/templates/taxonomy.md @@ -0,0 +1,176 @@ +--- +title: Taxonomy templates +description: Create a taxonomy template to render a list of terms. +categories: [templates] +keywords: [] +menu: + docs: + parent: templates + weight: 90 +weight: 90 +toc: true +aliases: [/taxonomies/displaying/,/templates/terms/,/indexes/displaying/,/taxonomies/templates/,/indexes/ordering/, /templates/taxonomies/, /templates/taxonomy-templates/] +--- + +The [taxonomy] template below inherits the site's shell from the [base template], and renders a list of [terms] in the current taxonomy. + +[taxonomy]: /getting-started/glossary/#taxonomy +[terms]: /getting-started/glossary/#term +[base template]: /templates/types/ + +{{< code file=layouts/_default/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +Review the [template lookup order] to select a template path that provides the desired level of specificity. + +[template lookup order]: /templates/lookup-order/#taxonomy-templates + +In the example above, the taxonomy and term will be capitalized if their respective pages are not backed by files. You can disable this in your site configuration: + +{{< code-toggle file=hugo >}} +capitalizeListTitles = false +{{< /code-toggle >}} + +## Data object + +Use these methods on the `Data` object within a taxonomy template. + +Singular +: (`string`) Returns the singular name of the taxonomy. + +```go-html-template +{{ .Data.Singular }} → tag +``` + +Plural +: (`string`) Returns the plural name of the taxonomy. + +```go-html-template +{{ .Data.Plural }} → tags +``` + +Terms +: (`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages] associated with each term. + +[weighted pages]: /getting-started/glossary/#weighted-page + +```go-html-template +{{ $taxonomyObject := .Data.Terms }} +``` + +Once we have the `Taxonomy` object, we can call any of its [methods], allowing us to sort alphabetically or by term count. + +[methods]: /methods/taxonomy/ + +## Sort alphabetically + +The taxonomy template below inherits the site's shell from the base template, and renders a list of terms in the current taxonomy. Hugo sorts the list alphabetically by term, and displays the number of pages associated with each term. + +{{< code file=layouts/_default/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Data.Terms.Alphabetical }} +

{{ .Page.LinkTitle }} ({{ .Count }})

+ {{ end }} +{{ end }} +{{< /code >}} + +## Sort by term count + +The taxonomy template below inherits the site's shell from the base template, and renders a list of terms in the current taxonomy. Hugo sorts the list by the number of pages associated with each term, and displays the number of pages associated with each term. + +{{< code file=layouts/_default/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Data.Terms.ByCount }} +

{{ .Page.LinkTitle }} ({{ .Count }})

+ {{ end }} +{{ end }} +{{< /code >}} + +## Include content links + +The [`Alphabetical`] and [`ByCount`] methods used in the previous examples return an [ordered taxonomy], so we can also list the content to which each term is assigned. + +[ordered taxonomy]: /getting-started/glossary/#ordered-taxonomy +[`Alphabetical`]: /methods/taxonomy/alphabetical/ +[`ByCount`]: /methods/taxonomy/bycount/ + +The taxonomy template below inherits the site's shell from the base template, and renders a list of terms in the current taxonomy. Hugo sorts the list by the number of pages associated with each term, displays the number of pages associated with each term, then lists the content to which each term is assigned. + +{{< code file=layouts/_default/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Data.Terms.ByCount }} +

{{ .Page.LinkTitle }} ({{ .Count }})

+ + {{ end }} +{{ end }} +{{< /code >}} + +## Display metadata + +Display metadata about each term by creating a corresponding branch bundle in the content directory. + +For example, create an "authors" taxonomy: + +{{< code-toggle file=hugo >}} +[taxonomies] +author = 'authors' +{{< /code-toggle >}} + +Then create content with one [branch bundle] for each term: + +[branch bundle]: /getting-started/glossary/#branch-bundle + +```text +content/ +└── authors/ + ├── jsmith/ + │ ├── _index.md + │ └── portrait.jpg + └── rjones/ + ├── _index.md + └── portrait.jpg +``` + +Then add front matter to each term page: + +{{< code-toggle file=content/authors/jsmith/_index.md fm=true >}} +title = "John Smith" +affiliation = "University of Chicago" +{{< /code-toggle >}} + +Then create a taxonomy template specific to the "authors" taxonomy: + +{{< code file=layouts/authors/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Data.Terms.Alphabetical }} +

{{ .Page.LinkTitle }}

+

Affiliation: {{ .Page.Params.Affiliation }}

+ {{ with .Page.Resources.Get "portrait.jpg" }} + {{ with .Fill "100x100" }} + portrait + {{ end }} + {{ end }} + {{ end }} +{{ end }} +{{< /code >}} + +In the example above we list each author including their affiliation and portrait. diff --git a/content/en/templates/term.md b/content/en/templates/term.md new file mode 100644 index 0000000000..5becd0aa0f --- /dev/null +++ b/content/en/templates/term.md @@ -0,0 +1,115 @@ +--- +title: Term templates +description: Create a term template to render a list of pages associated with the current term. +categories: [templates] +keywords: [] +menu: + docs: + parent: templates + weight: 100 +weight: 100 +toc: true +--- + +The [term] template below inherits the site's shell from the [base template], and renders a list of pages associated with the current term. + +[term]: /getting-started/glossary/#term +[base template]: /templates/types/ + +{{< code file=layouts/_default/term.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +Review the [template lookup order] to select a template path that provides the desired level of specificity. + +[template lookup order]: /templates/lookup-order/#taxonomy-templates + +In the example above, the term will be capitalized if its respective page is not backed by a file. You can disable this in your site configuration: + +{{< code-toggle file=hugo >}} +capitalizeListTitles = false +{{< /code-toggle >}} + +## Data object + +Use these methods on the `Data` object within a term template. + +Singular +: (`string`) Returns the singular name of the taxonomy. + +```go-html-template +{{ .Data.Singular }} → tag +``` + +Plural +: (`string`) Returns the plural name of the taxonomy. + +```go-html-template +{{ .Data.Plural }} → tags +``` + +Term +: (`string`) Returns the name of the term. + +```go-html-template +{{ .Data.Term }} → fiction +``` + +## Display metadata + +Display metadata about each term by creating a corresponding branch bundle in the content directory. + +For example, create an "authors" taxonomy: + +{{< code-toggle file=hugo >}} +[taxonomies] +author = 'authors' +{{< /code-toggle >}} + +Then create content with one [branch bundle] for each term: + +[branch bundle]: /getting-started/glossary/#branch-bundle + +```text +content/ +└── authors/ + ├── jsmith/ + │ ├── _index.md + │ └── portrait.jpg + └── rjones/ + ├── _index.md + └── portrait.jpg +``` + +Then add front matter to each term page: + +{{< code-toggle file=content/authors/jsmith/_index.md fm=true >}} +title = "John Smith" +affiliation = "University of Chicago" +{{< /code-toggle >}} + +Then create a term template specific to the "authors" taxonomy: + +{{< code file=layouts/authors/term.html >}} +{{ define "main" }} +

{{ .Title }}

+

Affiliation: {{ .Params.affiliation }}

+ {{ with .Resources.Get "portrait.jpg" }} + {{ with .Fill "100x100" }} + portrait + {{ end }} + {{ end }} + {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +In the example above we display the author with their affiliation and portrait, then a list of associated content. diff --git a/content/en/templates/types/index.md b/content/en/templates/types/index.md new file mode 100644 index 0000000000..934105d880 --- /dev/null +++ b/content/en/templates/types/index.md @@ -0,0 +1,284 @@ +--- +title: Template types +linkTitle: Template types +description: Create templates of different types to render your content, resources, and data. +categories: [templates] +keywords: [] +menu: + docs: + parent: templates + weight: 30 +weight: 30 +toc: true +aliases: ['/templates/lists/'] +--- + +[![structural diagram of a website](site-hierarchy.svg)](site-hierarchy.svg) + +## Structure + +Create templates in the layouts directory in the root of your project. + +Although your site may not require each of these templates, the example below is typical for a site of medium complexity. + +```text +layouts/ +├── _default/ +│ ├── _markup/ +│ │ ├── render-image.html <-- render hook +│ │ └── render-link.html <-- render hook +│ ├── baseof.html +│ ├── home.html +│ ├── section.html +│ ├── single.html +│ ├── taxonomy.html +│ └── term.html +├── articles/ +│ └── card.html <-- content view +├── partials/ +│ ├── footer.html +│ └── header.html +└── shortcodes/ + ├── audio.html + └── video.html +``` + +Hugo's [template lookup order] determines the template path, allowing you to create unique templates for any page. + +[template lookup order]: /templates/lookup-order/ + +{{% note %}} +You must have thorough understanding of the [template lookup order] when creating templates. Template selection is based on template type, page kind, content type, section, language, and output format. + +[template lookup order]: /templates/lookup-order/ +{{% /note %}} + +The purpose of each template type is described below. + +## Base + +Base templates reduce duplicate code by wrapping other templates within a shell. + +For example, the base template below calls the [partial] function to include partial templates for the `head`, `header`, and `footer` elements of each page, and it uses the [block] function to include `home`, `single`, `section`, `taxonomy`, and `term` templates within the `main` element of each page. + +[block]: /functions/go-template/block/ +[partial]: /functions/partials/include/ + +{{< code file=layouts/_default/baseof.html >}} + + + + {{ partial "head.html" . }} + + +
+ {{ partial "header.html" . }} +
+
+ {{ block "main" . }}{{ end }} +
+
+ {{ partial "footer.html" . }} +
+ + +{{< /code >}} + +Learn more about [base templates](/templates/base/). + +## Home + +A home template renders your site's home page. For a single page site this is the only required template. + +For example, the home template below inherits the site's shell from the base template, and renders the home page content with a list of pages. + +{{< code file=layouts/_default/home.html >}} +{{ define "main" }} + {{ .Content }} + {{ range site.RegularPages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +{{% include "templates/_common/filter-sort-group.md" %}} + +Learn more about [home templates](/templates/home/). + +## Single + +A single template renders a single page. + +For example, the single template below inherits the site's shell from the base template, and renders the title and content of each page. + +{{< code file=layouts/_default/single.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} +{{ end }} +{{< /code >}} + +Learn more about [single templates](/templates/single/). + +## Section + +A section template typically renders a list of pages within a section. + +For example, the section template below inherits the site's shell from the base template, and renders a list of pages in the current section. + +{{< code file=layouts/_default/section.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +{{% include "templates/_common/filter-sort-group.md" %}} + +Learn more about [section templates](/templates/section/). + +## Taxonomy + +A taxonomy template renders a list of terms in a [taxonomy]. + +[taxonomy]: /getting-started/glossary/#taxonomy + +For example, the taxonomy template below inherits the site's shell from the base template, and renders a list of terms in the current taxonomy. + +{{< code file=layouts/_default/taxonomy.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +{{% include "templates/_common/filter-sort-group.md" %}} + +Learn more about [taxonomy templates](/templates/taxonomy/). + +## Term + +A term template renders a list of pages associated with a [term]. + +[term]: /getting-started/glossary/#term + +For example, the term template below inherits the site's shell from the base template, and renders a list of pages associated with the current term. + +{{< code file=layouts/_default/term.html >}} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ {{ end }} +{{ end }} +{{< /code >}} + +{{% include "templates/_common/filter-sort-group.md" %}} + +Learn more about [term templates](/templates/term/). + +## Partial + +A partial template is typically used to render a component of your site, though you may also create partial templates that return values. + +{{% note %}} +Unlike other template types, you cannot create partial templates to target a particular page kind, content type, section, language, or output format. Partial templates do not follow Hugo's [template lookup order]. + +[template lookup order]: /templates/lookup-order/ +{{% /note %}} + +For example, the partial template below renders copyright information. + +{{< code file=layouts/partials/footer.html >}} +

Copyright {{ now.Year }}. All rights reserved.

+{{< /code >}} + +Learn more about [partial templates](/templates/partial/). + +## Content view + +A content view template is similar to a partial template, invoked by calling the [`Render`] method on a `Page` object. Unlike partial templates, content view templates: + +- Automatically inherit the context of the current page +- Follow a lookup order allowing you to target a given content type or section + +[`Render`]: /methods/page/render/ + +For example, the home template below inherits the site's shell from the base template, and renders a card component for each page within the "articles" section of your site. + +{{< code file=layouts/_default/home.html >}} +{{ define "main" }} + {{ .Content }} +
    + {{ range where site.RegularPages "Section" "articles" }} + {{ .Render "card" }} + {{ end }} +
+{{ end }} +{{< /code >}} + +{{< code file=layouts/articles/card.html >}} +
+

{{ .LinkTitle }}

+ {{ .Summary }} +
+{{< /code >}} + +Learn more about [content view templates](/templates/content-view/). + +## Render hook + +A render hook template overrides the conversion of Markdown to HTML. + +For example, the render hook template below adds a `rel` attribute to external links. + +{{< code file=layouts/_default/_markup/render-link.html >}} +{{- $u := urls.Parse .Destination -}} + + {{- with .Text | safeHTML }}{{ . }}{{ end -}} + +{{- /* chomp trailing newline */ -}} +{{< /code >}} + +Learn more about [render hook templates](/render-hooks/). + +## Shortcode + +A shortcode template is used to render a component of your site. Unlike partial templates, shortcode templates are called from content pages. + +For example, the shortcode template below renders an audio element from a [global resource]. + +[global resource]: /getting-started/glossary/#global-resource + +{{< code file=layouts/shortcodes/audio.html >}} +{{ with resources.Get (.Get "src") }} + +{{ end }} +{{< /code >}} + +Call the shortcode from your content page: + +{{< code file=content/example.md >}} +{{}} +{{< /code >}} + +Learn more about [shortcode templates](/templates/shortcode/). + +## Other + +Use other specialized templates to create: + +- [Sitemaps](/templates/sitemap) +- [RSS feeds](/templates/rss/) +- [404 error pages](/templates/404/) +- [robots.txt files](/templates/robots/) diff --git a/content/en/templates/lists/site-hierarchy.svg b/content/en/templates/types/site-hierarchy.svg similarity index 100% rename from content/en/templates/lists/site-hierarchy.svg rename to content/en/templates/types/site-hierarchy.svg