Merge commit '87de22d7464e239c775fbd48ebce1665d5b1e80d'

This commit is contained in:
Bjørn Erik Pedersen
2023-07-29 11:17:28 +02:00
177 changed files with 1623 additions and 1556 deletions

View File

@@ -1,9 +1,10 @@
---
title: Content Management
linkTitle: Content Management Overview
title: Content management
linkTitle: Overview
description: Hugo makes managing large static sites easy with support for archetypes, content types, menus, cross references, summaries, and more.
menu:
docs:
identifier: content-management-overview
parent: content-management
weight: 10
keywords: [source, organization]

View File

@@ -13,7 +13,7 @@ weight: 140
aliases: [/content/archetypes/]
---
## What are Archetypes?
## What are archetypes?
**Archetypes** are content template files in the [archetypes directory] of your project that contain preconfigured [front matter] and possibly also a content disposition for your website's [content types]. These will be used when you run `hugo new`.
@@ -33,7 +33,7 @@ The above will create a new content file in `content/posts/my-first-post.md` usi
The last two list items are only applicable if you use a theme and it uses the `my-theme` theme name as an example.
## Create a New Archetype Template
## Create a new archetype template
A fictional example for the section `newsletter` and the archetype file `archetypes/newsletter.md`. Create a new file in `archetypes/newsletter.md` and open it in a text editor.
@@ -46,7 +46,7 @@ draft: true
**Insert Lead paragraph here.**
## New Cool Posts
## New cool posts
{{ range first 10 ( where .Site.RegularPages "Type" "cool" ) }}
* {{ .Title }}

View File

@@ -1,9 +1,8 @@
---
title: Build Options
linkTitle: Build Options
title: Build options
description: Build options help define how Hugo must treat a given page when building the site.
keywords: [build,content,front matter, page resources]
categories: [content management]
categories: [fundamentals,content management]
menu:
docs:
parent: content-management
@@ -13,7 +12,7 @@ weight: 70
aliases: [/content/build-options/]
---
They are stored in a reserved Front Matter object named `_build` with the following defaults:
They are stored in a reserved front matter object named `_build` with the following defaults:
{{< code-toggle >}}
_build:
@@ -26,38 +25,30 @@ _build:
If `always`, the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink.
We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are:
Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be rendered to disk and get a `RelPermalink` etc.
link
: The page will be not be rendered to disk, but will get a `RelPermalink`.
- `never`
: The page will not be included in any page collection.
- `always (default)`
: The page will be rendered to disk and get a `RelPermalink` etc.
- `link`
: The page will be not be rendered to disk, but will get a `RelPermalink`.
#### list
Note that we extended this property from a boolean to an enum in Hugo 0.68.0.
Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be included in all page collections, e.g. `site.RegularPages`, `$page.Pages`.
local
: The page will be included in any _local_ page collection, e.g. `$page.RegularPages`, `$page.Pages`. One use case for this would be to create fully navigable, but headless content sections.
If true, the page will be treated as part of the project's collections and, when appropriate, returned by Hugo's listing methods (`.Pages`, `.RegularPages` etc...).
- `never`
: The page will not be included in any page collection.
- `always (default)`
: The page will be included in all page collections, e.g. `site.RegularPages`, `.Pages`.
- `local`
: The page will be included in any _local_ page collection, e.g. `.RegularPages`, `.Pages`. One use case for this would be to create fully navigable, but headless content sections.
#### publishResources
If set to true the [Bundle's Resources](/content-management/page-bundles) will be published.
Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
If set to `true` (default) the [Bundle's Resources](/content-management/page-bundles) will be published.
Setting this to `false` will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
{{% note %}}
Any page, regardless of their build options, will always be available using the [`.GetPage`](/functions/getpage) methods.
@@ -67,7 +58,7 @@ Any page, regardless of their build options, will always be available using the
#### Not publishing a page
Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else.
Project needs a "Who We Are" content file for front matter and body to be used by the homepage but nowhere else.
{{< code-toggle file="content/who-we-are.md" fm=true copy=false >}}
title: Who we are

View File

@@ -2,7 +2,7 @@
title: Comments
description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website.
keywords: [sections,content,organization]
categories: [project organization, fundamentals]
categories: [project organization]
menu:
docs:
parent: content-management
@@ -34,9 +34,9 @@ For many websites, this is enough configuration. However, you also have the opti
* `disqus_title`
* `disqus_url`
### Render Hugo's Built-in Disqus Partial Template
### Render Hugo's built-in Disqus partial template
Disqus has its own [internal template](https://gohugo.io/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
Disqus has its own [internal template](/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
```go-html-template
{{ template "_internal/disqus.html" . }}

View File

@@ -1,6 +1,5 @@
---
title: Links and Cross References
linkTitle: Links and Cross References
title: Links and cross references
description: Shortcodes for creating links to documents.
categories: [content management]
keywords: ["cross references","references", "anchors", "urls"]
@@ -19,7 +18,7 @@ The `ref` and `relref` shortcodes display the absolute and relative permalinks t
The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site.
```
```text
.
└── content
├── about
@@ -78,7 +77,7 @@ To link to another language version of a document, use this syntax:
{{</* relref path="document.md" lang="ja" */>}}
```
### Get another Output Format
### Get another output format
To link to another Output Format of a document, use this syntax:

View File

@@ -12,7 +12,7 @@ weight: 50
---
{{< new-in "0.93.0" >}}
## GoAT Diagrams (Ascii)
## GoAT diagrams (Ascii)
Hugo supports [GoAT](https://github.com/bep/goat) natively. This means that this code block:
@@ -42,14 +42,14 @@ Will be rendered as:
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
```
## Mermaid Diagrams
## Mermaid diagrams
Hugo currently does not provide default templates for Mermaid diagrams. But you can easily add your own. One way to do it would be to create `layouts/_default/_markup/render-codeblock-mermaid.html`:
```go-html-template
<div class="mermaid">
<pre class="mermaid">
{{- .Inner | safeHTML }}
</div>
</pre>
{{ .Page.Store.Set "hasMermaid" true }}
```
@@ -66,7 +66,7 @@ And then include this snippet at the bottom of the content template (**Note**: b
With that you can use the `mermaid` language in Markdown code blocks:
````
````text
```mermaid
sequenceDiagram
participant Alice
@@ -82,7 +82,7 @@ sequenceDiagram
```
````
## Goat Ascii Diagram Examples
## Goat ASCII diagram examples
### Graphics
@@ -166,7 +166,7 @@ Created from <https://arthursonzogni.com/Diagon/#Tree>
```
### Sequence Diagram
### Sequence diagram
<https://arthursonzogni.com/Diagon/#Sequence>

View File

@@ -1,6 +1,5 @@
---
title: Content Formats
linkTitle: Content Formats
title: Content formats
description: Both HTML and Markdown are supported content formats.
categories: [content management]
keywords: [markdown,asciidoc,pandoc,content format]
@@ -34,7 +33,7 @@ The current list of content formats in Hugo:
The `markup identifier` is fetched from either the `markup` variable in front matter or from the file extension. For markup-related configuration, see [Configure Markup](/getting-started/configuration-markup/).
## External Helpers
## External helpers
Some of the formats in the table above need external helpers installed on your PC. For example, for AsciiDoc files,
Hugo will try to call the `asciidoctor` command. This means that you will have to install the associated
@@ -50,13 +49,7 @@ Hugo passes reasonable default arguments to these external helpers by default:
Because additional formats are external commands, generation performance will rely heavily on the performance of the external tool you are using. As this feature is still in its infancy, feedback is welcome.
{{% /note %}}
### External Helper AsciiDoc
[AsciiDoc](https://github.com/asciidoc/asciidoc) implementation EOLs in Jan 2020 and is no longer supported.
AsciiDoc development is being continued under [Asciidoctor](https://github.com/asciidoctor). The format AsciiDoc
remains of course. Please continue with the implementation Asciidoctor.
### External Helper Asciidoctor
### External helper Asciidoctor
The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo.
[See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/). Make sure that also all
@@ -113,7 +106,7 @@ parameters. Run Hugo with `-v`. You will get an output like
INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ...
```
## Learn Markdown
## Learn markdown
Markdown syntax is simple enough to learn in a single sitting. The following are excellent resources to get you up and running:

View File

@@ -1,5 +1,5 @@
---
title: Front Matter
title: Front matter
description: Hugo allows you to add front matter in yaml, toml, or json to your content files.
categories: [content management]
keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"]
@@ -16,7 +16,7 @@ aliases: [/content/front-matter/]
{{< youtube Yh2xKRJGff4 >}}
## Front Matter Formats
## Front matter formats
Hugo supports four formats for front matter, each with their own identifying tokens.
@@ -47,7 +47,7 @@ categories = [
slug = "spf13-vim-3-0-release-and-new-website"
{{< /code-toggle >}}
## Front Matter Variables
## Front matter variables
### Predefined
@@ -93,7 +93,7 @@ lastmod
: The datetime at which the content was last modified.
linkTitle
: Used for creating links to content; if set, Hugo defaults to using the `linktitle` before the `title`. Hugo can also [order lists of content by `linktitle`][bylinktitle].
: Used for creating links to content; if set, Hugo defaults to using the `linkTitle` before the `title`. Hugo can also [order lists of content by `linkTitle`][bylinktitle].
markup
: **experimental**; specify `"rst"` for reStructuredText (requires`rst2html`) or `"md"` (default) for Markdown.
@@ -135,10 +135,10 @@ weight
: Field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.*
{{% note %}}
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site configuration file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site configuration file](/content-management/urls/#permalinks), Hugo will use the file name of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
{{% /note %}}
### User-Defined
### User-defined
You can add fields to your front matter arbitrarily to meet your needs. These user-defined key-values are placed into a single `.Params` variable for use in your templates.
@@ -149,11 +149,11 @@ include_toc: true
show_comments: false
{{</ code-toggle >}}
## Front Matter Cascade
## Front matter cascade
Any node or section can pass down to descendants a set of Front Matter values as long as defined underneath the reserved `cascade` Front Matter key.
Any node or section can pass down to descendants a set of front matter values as long as defined underneath the reserved `cascade` front matter key.
### Target Specific Pages
### Target specific pages
The `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
@@ -202,15 +202,15 @@ With the above example the Blog section page and its descendants will return `im
- Said descendant has its own `banner` value set
- Or a closer ancestor node has its own `cascade.banner` value set.
## Order Content Through Front Matter
## Order content through front matter
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.
## Override Global Markdown Configuration
## Override global markdown configuration
It's possible to set some options for Markdown rendering in a content's front matter as an override to the [Rendering options set in your project configuration][config].
It's possible to set some options for Markdown rendering in a content's front matter as an override to the [rendering options set in your project configuration][config].
## Front Matter Format Specs
## Front matter format specs
- [TOML Spec][toml]
- [YAML Spec][yaml]
@@ -220,15 +220,15 @@ It's possible to set some options for Markdown rendering in a content's front ma
[aliases]: /content-management/urls/#aliases
[archetype]: /content-management/archetypes/
[bylinktitle]: /templates/lists/#by-link-title
[config]: /getting-started/configuration/ "Hugo documentation for site configuration"
[config]: /getting-started/configuration/
[content type]: /content-management/types/
[contentorg]: /content-management/organization/
[headless-bundle]: /content-management/page-bundles/#headless-bundle
[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation"
[lists]: /templates/lists/#order-content "See how to order content in list pages; for example, templates that look to specific _index.md for content and front matter."
[lookup]: /templates/lookup-order/ "Hugo traverses your templates in a specific order when rendering content to allow for DRYer templating."
[ordering]: /templates/lists/ "Hugo provides multiple ways to sort and order your content in list templates"
[outputs]: /templates/output-formats/ "With the release of v22, you can output your content to any text format using Hugo's familiar templating"
[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
[lists]: /templates/lists/#order-content
[lookup]: /templates/lookup-order/
[ordering]: /templates/lists/
[outputs]: /templates/output-formats/
[page-resources]: /content-management/page-resources/
[pagevars]: /variables/page/
[section]: /content-management/sections/
@@ -236,4 +236,4 @@ It's possible to set some options for Markdown rendering in a content's front ma
[toml]: https://toml.io/
[urls]: /content-management/urls/
[variables]: /variables/
[yaml]: https://yaml.org/spec/ "Specification for YAML, YAML Ain't Markup Language"
[yaml]: https://yaml.org/spec/

View File

@@ -1,7 +1,7 @@
---
title: Image Processing
title: Image processing
description: Resize, crop, rotate, filter, and convert images.
categories: [content management]
categories: [fundamentals,content management]
keywords: [resources, images]
menu:
docs:
@@ -10,11 +10,11 @@ menu:
toc: true
weight: 90
---
## Image Resources
## Image resources
To process an image, you must access the image as either a page resource or a global resource.
### Page Resources
### Page resources
A page resource is a file within a [page bundle]. A page bundle is a directory with an `index.md` or `_index.md` file at its root.
@@ -26,7 +26,7 @@ content/
└── sunset.jpg <-- page resource
```
### Global Resources
### Global resources
A global resource is a file:
@@ -52,7 +52,7 @@ To access a remote image as a global resource:
{{ $image := resources.GetRemote "https://gohugo.io/img/hugo-logo.png" }}
```
## Image Rendering
## 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.
@@ -80,12 +80,12 @@ Example 3: A more concise way to skip image rendering if the resource is not fou
{{ end }}
```
## Image Processing Methods
## Image processing methods
The `image` resource implements the [`Resize`], [`Fit`], [`Fill`], [`Crop`], [`Filter`], [`Colors`] and [`Exif`] methods.
{{% note %}}
Metadata (Exif, IPTC, XMP, etc.) is not preserved during image transformation. Use the [`Exif`] method with the _original_ image to extract Exif metadata from JPEG or TIFF images.
Metadata (EXIF, IPTC, XMP, etc.) is not preserved during image transformation. Use the [`Exif`] method with the _original_ image to extract EXIF metadata from JPEG or TIFF images.
{{% /note %}}
### Resize
@@ -164,11 +164,11 @@ Sometimes it can be useful to create the filter chain once and then reuse it.
This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled down image.
### Exif
### EXIF
Provides an [Exif] object containing image metadata.
Provides an [EXIF] object containing image metadata.
You may access Exif data in JPEG and TIFF images. To prevent errors when processing images without Exif data, wrap the access in a [`with`] statement.
You may access EXIF data in JPEG and TIFF images. To prevent errors when processing images without EXIF data, wrap the access in a [`with`] statement.
```go-html-template
{{ with $image.Exif }}
@@ -181,7 +181,7 @@ You may access Exif data in JPEG and TIFF images. To prevent errors when process
{{ end }}
```
You may also access Exif fields individually, using the [`lang.FormatNumber`] function to format the fields as needed.
You may also access EXIF fields individually, using the [`lang.FormatNumber`] function to format the fields as needed.
```go-html-template
{{ with $image.Exif }}
@@ -198,7 +198,7 @@ You may also access Exif fields individually, using the [`lang.FormatNumber`] fu
{{ end }}
```
#### Exif Variables
#### EXIF variables
.Date
: Image creation date/time. Format with the [time.Format] function.
@@ -210,9 +210,9 @@ You may also access Exif fields individually, using the [`lang.FormatNumber`] fu
: GPS longitude in degrees.
.Tags
: A collection of the available Exif tags for this image. You may include or exclude specific tags from this collection in the [site configuration](#exif-data).
: A collection of the available EXIF tags for this image. You may include or exclude specific tags from this collection in the [site configuration](#exif-data).
## Image Processing Options
## Image processing options
The [`Resize`], [`Fit`], [`Fill`], and [`Crop`] methods accept a space-separated, case-insensitive list of options. The order of the options within the list is irrelevant.
@@ -265,7 +265,7 @@ For example, if you have a 400x200 image with a bird in the upper left quadrant,
If you apply [rotation](#rotation) when using the [`Crop`] or [`Fill`] method, specify the anchor relative to the rotated image.
### Target Format
### Target format
By default, Hugo encodes the image in the source format. You may convert the image to another format by specifying `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, or `webp`.
@@ -313,7 +313,7 @@ The default value is `photo`. You may override the default value in the [site co
{{ $image.Resize "600x webp picture" }}
```
### Background Color
### Background color
When converting an image from a format that supports transparency (e.g., PNG) to a format that does _not_ support transparency (e.g., JPEG), you may specify the background color of the resulting image.
@@ -325,7 +325,7 @@ The default value is `#ffffff` (white). You may override the default value in th
{{ $image.Resize "600x jpg #b31280" }}
```
### Resampling Filter
### Resampling filter
You may specify the resampling filter used when resizing an image. Commonly used resampling filters include:
@@ -346,7 +346,7 @@ The default value is `Box`. You may override the default value in the [site conf
See [github.com/disintegration/imaging] for the complete list of resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
## Image Processing Examples
## Image processing examples
_The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_
@@ -378,9 +378,9 @@ Call the shortcode from your Markdown like this:
Note the self-closing shortcode syntax above. You may call the `imgproc` shortcode with or without **inner content**.
{{% /note %}}
## Imaging Configuration
## Imaging configuration
### Processing Options
### Processing options
Define an `imaging` section in your site configuration to set the default [image processing options](#image-processing-options).
@@ -408,9 +408,9 @@ quality
resampleFilter
: See image processing options: [resampling filter](#resampling-filter).
### Exif Data
### EXIF data
Define an `imaging.exif` section in your site configuration to control the availability of Exif data.
Define an `imaging.exif` section in your site configuration to control the availability of EXIF data.
{{< code-toggle file="hugo" copy=true >}}
[imaging.exif]
@@ -427,16 +427,16 @@ disableLatLong
: Hugo extracts the GPS latitude and longitude into `.Lat` and `.Long`. Set this to `true` to disable. Default is `false`.
excludeFields
: Regular expression matching the Exif tags to exclude from the `.Tags` collection. Default is&nbsp;`""`.
: Regular expression matching the EXIF tags to exclude from the `.Tags` collection. Default is&nbsp;`""`.
includeFields
: Regular expression matching the Exif tags to include in the `.Tags` collection. Default is&nbsp;`""`. To include all available tags, set this value to&nbsp;`".*"`.
: Regular expression matching the EXIF tags to include in the `.Tags` collection. Default is&nbsp;`""`. To include all available tags, set this value to&nbsp;`".*"`.
{{% note %}}
To improve performance and decrease cache size, if you set neither `excludeFields` nor `includeFields`, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`.
{{% /note %}}
## Smart Cropping of Images
## Smart cropping of images
By default, Hugo uses the [Smartcrop] library when cropping images with the `Crop` or`Fill` methods. You can set the anchor point manually, but in most cases the `Smart` option will make a good choice.
@@ -446,7 +446,7 @@ Examples using the sunset image from above:
{{< imgproc sunset Crop "200x200 smart" />}}
## Image Processing Performance Consideration
## Image processing performance consideration
Hugo caches processed images in the `resources` directory. If you include this directory in source control, Hugo will not have to regenerate the images in a CI/CD workflow (e.g., GitHub Pages, GitLab Pages, Netlify, etc.). This results in faster builds.
@@ -458,7 +458,7 @@ hugo --gc
[time.Format]: /functions/dateformat
[`anchor`]: /content-management/image-processing#anchor
[mounted]: /hugo-modules/configuration#module-config-mounts
[mounted]: /hugo-modules/configuration#module-configuration-mounts
[page bundle]: /content-management/page-bundles
[`lang.FormatNumber`]: /functions/lang
[filters]: /functions/images

View File

@@ -1,5 +1,5 @@
---
title: Multilingual Mode
title: Multilingual mode
linkTitle: Multilingual
description: Hugo supports the creation of websites with multiple languages side by side.
categories: [content management]
@@ -17,57 +17,79 @@ You should define the available languages in a `languages` section in your site
Also See [Hugo Multilingual Part 1: Content translation].
## Configure Languages
## Configure languages
The following is an example of a site configuration for a multilingual Hugo project:
This is an example of a site configuration for a multilingual project. Any key not defined in a `languages` object will fall back to the global value in the root of your site configuration.
{{< code-toggle file="hugo" >}}
defaultContentLanguage = "en"
copyright = "Everything is mine"
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = true
[params]
[params.navigation]
help = "Help"
[languages]
[languages.en]
title = "My blog"
[languages.de]
contentDir = 'content/de'
disabled = false
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.de.params]
subtitle = 'Referenz, Tutorials und Erklärungen'
[languages.en]
contentDir = 'content/en'
disabled = false
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Project Documentation'
weight = 2
[languages.en.params]
linkedin = "https://linkedin.com/whoever"
[languages.fr]
title = "Mon blogue"
weight = 2
[languages.fr.params]
linkedin = "https://linkedin.com/fr/whoever"
[languages.fr.params.navigation]
help = "Aide"
[languages.ar]
title = "مدونتي"
weight = 2
languagedirection = "rtl"
[languages.pt-pt]
title = "O meu blog"
weight = 3
subtitle = 'Reference, Tutorials, and Explanations'
{{< /code-toggle >}}
Anything not defined in a `languages` block will fall back to the global value for that key (e.g., `copyright` for the English `en` language). This also works for `params`, as demonstrated with `help` above: You will get the value `Aide` in French and `Help` in all the languages without this parameter set.
`defaultContentLanguage`
: (`string`) The project's default language tag as defined by [RFC 5646]. Must be lower case, and must match one of the defined language keys. Default is `en`. Examples:
With the configuration above, all content, sitemap, RSS feeds, pagination,
and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French.
- `en`
- `en-gb`
- `pt-br`
When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation.
`defaultContentLanguageInSubdir`
: (`bool`) If `true`, Hugo renders the default language site in a subdirectory matching the `defaultContentLanguage`. Default is `false`.
`defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`.
`contentDir`
: (`string`) The content directory for this language. Omit if [translating by file name].
If the default language needs to be rendered below its own language code (`/en`) like the others, set `defaultContentLanguageInSubdir: true`.
`disabled`
: (`bool`) If `true`, Hugo will not render content for this language. Default is `false`.
Only the obvious non-global options can be overridden per language. Examples of global options are `baseURL`, `buildDrafts`, etc.
`languageCode`
: (`string`) The language tag as defined by [RFC 5646]. This value may include upper and lower case characters, hyphens or underscores, and does not affect localization or URLs. Hugo uses this value to populate the `language` element in the [built-in RSS template], and the `lang` attribute of the `html` element in the [built-in alias template]. Examples:
**Please note:** use lowercase language codes, even when using regional languages (ie. use pt-pt instead of pt-PT). Currently Hugo language internals lowercase language codes, which can cause conflicts with settings like `defaultContentLanguage` which are not lowercased. Please track the evolution of this issue in [Hugo repository issue tracker](https://github.com/gohugoio/hugo/issues/7344)
- `en`
- `en-GB`
- `pt-BR`
`languageDirection`
: (`string`) The language direction, either left-to-right (`ltr`) or right-to-left (`rtl`). Use this value in your templates with the global [`dir`] HTML attribute.
`languageName`
: (`string`) The language name, typically used when rendering a language switcher.
`title`
: (`string`) The language title. When set, this overrides the site title for this language.
`weight`
: (`int`) The language weight. When set to a non-zero value, this is the primary sort criteria for this language.
[`dir`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[built-in RSS template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml
[built-in alias template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/alias.html
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[translating by file name]: #translation-by-file-name
### Changes in Hugo 0.112.0
@@ -76,7 +98,7 @@ Only the obvious non-global options can be overridden per language. Examples of
In Hugo `v0.112.0` we consolidated all configuration options, and improved how the languages and their parameters are merged with the main configuration. But while testing this on Hugo sites out there, we received some error reports and reverted some of the changes in favor of deprecation warnings:
1. `site.Language.Params` is deprecated. Use `site.Params` directly.
1. Adding custom params to the top level language config is deprecated, add all of these below `[params]`, see `color` in the example below.
1. Adding custom parameters to the top level language configuration is deprecated, add all of these below `[params]`, see `color` in the example below.
```toml
title = "My blog"
@@ -92,35 +114,36 @@ color = "blue"
In the example above, all settings except `color` below `params` map to predefined configuration options in Hugo for the site and its language, and should be accessed via the documented accessors:
```
```go-html-template
{{ site.Title }}
{{ site.LanguageCode }}
{{ site.Params.color }}
```
### Disable a Language
### Disable a language
You can disable one or more languages. This can be useful when working on a new translation.
To disable a language within a `languages` object in your site configuration:
{{< code-toggle file="hugo" >}}
disableLanguages = ["fr", "ja"]
{{< code-toggle file="hugo" copy=false >}}
[languages.es]
disabled = true
{{< /code-toggle >}}
To disable one or more languages in the root of your site configuration:
{{< code-toggle file="hugo" copy=false >}}
disableLanguages = ["es", "fr"]
{{< /code-toggle >}}
To disable one or more languages using an environment variable:
```bash
HUGO_DISABLELANGUAGES="es fr" hugo
```
Note that you cannot disable the default content language.
We kept this as a standalone setting to make it easier to set via [OS environment]:
```bash
HUGO_DISABLELANGUAGES="fr ja" hugo
```
If you have already a list of disabled languages in `hugo.toml`, you can enable them in development like this:
```bash
HUGO_DISABLELANGUAGES=" " hugo server
```
### Configure Multilingual Multihost
### Configure multilingual multihost
From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details.
@@ -167,12 +190,11 @@ Press Ctrl+C to stop
Live reload and `--navigateToChanged` between the servers work as expected.
## Translate Your Content
## Translate your content
There are two ways to manage your content translations. Both ensure each page is assigned a language and is linked to its counterpart translations.
### Translation by filename
### Translation by file name
Considering the following example:
@@ -182,9 +204,9 @@ Considering the following example:
The first file is assigned the English language and is linked to the second.
The second file is assigned the French language and is linked to the first.
Their language is __assigned__ according to the language code added as a __suffix to the filename__.
Their language is __assigned__ according to the language code added as a __suffix to the file name__.
By having the same **path and base filename**, the content pieces are __linked__ together as translated pages.
By having the same **path and base file name**, the content pieces are __linked__ together as translated pages.
{{% note %}}
If a file has no language code, it will be assigned the default language.
@@ -192,7 +214,7 @@ If a file has no language code, it will be assigned the default language.
### Translation by content directory
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param.
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` parameter.
{{< code-toggle file="hugo" >}}
languages:
@@ -234,11 +256,11 @@ Considering the following example:
translationKey: "about"
{{< /code-toggle >}}
By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages.
By setting the `translationKey` front matter parameter to `about` in all three pages, they will be __linked__ as translated pages.
### Localizing permalinks
Because paths and filenames are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).
Because paths and file names are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).
To localize URLs:
@@ -257,7 +279,7 @@ slug: "a-propos"
At render, Hugo will build both `/about/` and `/fr/a-propos/` without affecting the translation link.
### Page Bundles
### Page bundles
To avoid the burden of having to duplicate files, each Page Bundle inherits the resources of its linked translated pages' bundles except for the content files (Markdown files, HTML files etc...).
@@ -269,10 +291,10 @@ If, across the linked bundles, two or more files share the same basename, only o
* First file found across bundles by order of language `Weight`.
{{% note %}}
Page Bundle resources follow the same language assignment logic as content files, both by filename (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
Page Bundle resources follow the same language assignment logic as content files, both by file name (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
{{%/ note %}}
## Reference the Translated Content
## Reference translated content
To create a list of links to translated content, use a template similar to the following:
@@ -293,7 +315,7 @@ The above can be put in a `partial` (i.e., inside `layouts/partials/`) and inclu
The above also uses the [`i18n` function][i18func] described in the next section.
### List All Available Languages
### List all available languages
`.AllTranslations` on a `Page` can be used to list all translations, including the page itself. On the home page it can be used to build a language navigator:
@@ -305,7 +327,7 @@ The above also uses the [`i18n` function][i18func] described in the next section
</ul>
{{< /code >}}
## Translation of Strings
## Translation of strings
Hugo uses [go-i18n] to support string translations. [See the project's source repository][go-i18n-source] to find tools that will help you manage your translation workflows.
@@ -585,7 +607,7 @@ weight = 20
For a simple menu with two languages, these menu entries are easy to create and maintain. For a larger menu, or with more than two languages, using translation tables as described above is preferable.
## Missing Translations
## Missing translations
If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
@@ -604,7 +626,7 @@ hugo --printI18nWarnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount
```
## Multilingual Themes support
## Multilingual themes support
To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there is more than one language, URLs must meet the following criteria:

View File

@@ -1,8 +1,8 @@
---
title: Content Organization
title: Content organization
linkTitle: Organization
description: Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.
categories: [content management,fundamentals]
categories: [fundamentals,content management]
keywords: [sections,content,organization,bundle,resources]
menu:
docs:
@@ -13,7 +13,7 @@ weight: 20
aliases: [/content/sections/]
---
## Page Bundles
## Page bundles
Hugo `0.32` announced page-relative images and other resources packaged into `Page Bundles`.
@@ -29,7 +29,7 @@ The bundle documentation is a **work in progress**. We will publish more compreh
{{% /note %}}
## Organization of Content Source
## Organization of content source
In Hugo, your content should be organized in a manner that reflects the rendered website.
@@ -52,12 +52,12 @@ Without any additional configuration, the following will automatically work:
└── second.md // <- https://example.com/quote/second/
```
## Path Breakdown in Hugo
## Path breakdown in Hugo
The following demonstrates the relationships between your content organization and the output URL structure for your Hugo website when it renders. These examples assume you are [using pretty URLs][pretty], which is the default behavior for Hugo. The examples also assume a key-value of `baseURL = "https://example.com"` in your [site's configuration file][config].
### Index Pages: `_index.md`
### 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].
@@ -94,7 +94,7 @@ https://example.com/posts/index.html
The [sections] can be nested as deeply as you want. The important thing to understand is that to make the section tree fully navigational, at least the lower-most section must include a content file. (i.e. `_index.md`).
### Single Pages in Sections
### 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`:
@@ -121,7 +121,7 @@ https://example.com/posts/my-first-hugo-post/index.html
```
## Paths Explained
## Paths explained
The following concepts provide more insight into the relationship between your project's organization and the default Hugo behavior when building output for the website.

View File

@@ -1,5 +1,5 @@
---
title: Page Bundles
title: Page bundles
description: Content organization using Page Bundles
keywords: [page, bundle, leaf, branch]
categories: [content management]
@@ -19,23 +19,22 @@ A Page Bundle can be one of:
- Branch Bundle (home page, section, taxonomy terms, taxonomy list)
| | Leaf Bundle | Branch Bundle |
|-------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|-------------------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) |
| Index filename | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Allowed Resources | Page and non-page (like images, PDF, etc.) types | Only non-page (like images, PDF, etc.) types |
| Where can the Resources live? | At any directory level within the leaf bundle directory. | Only in the directory level **of** the branch bundle directory i.e. the directory containing the `_index.md` ([ref](https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi)). |
| Layout type | `single` | `list` |
| Layout type | [`single`](/templates/single-page-templates/) | [`list`](/templates/lists) |
| Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it |
| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` |
| Content from non-index page files... | Accessed only as page resources | Accessed only as regular pages |
| Content from non-index page files...| Accessed only as page resources | Accessed only as regular pages |
## Leaf Bundles {#leaf-bundles}
## Leaf bundles
A _Leaf Bundle_ is a directory at any hierarchy within the `content/`
directory, that contains an **`index.md`** file.
### Examples of Leaf Bundle organization {#examples-of-leaf-bundle-organization}
### Examples of leaf bundle organization {#examples-of-leaf-bundle-organization}
```text
content/
@@ -92,7 +91,7 @@ as long as it is not inside another **leaf** bundle.
{{% /note %}}
### Headless Bundle {#headless-bundle}
### Headless bundle
A headless bundle is a bundle that is configured to not get published
anywhere:
@@ -126,7 +125,7 @@ Explanation of the above example:
---
A leaf bundle can be made headless by adding below in the Front Matter
A leaf bundle can be made headless by adding below in the front matter
(in the `index.md`):
{{< code-toggle file="content/headless/index.md" fm=true copy=false >}}
@@ -138,7 +137,7 @@ There are many use cases of such headless page bundles:
- Shared media galleries
- Reusable page content "snippets"
## Branch Bundles {#branch-bundles}
## Branch bundles
A _Branch Bundle_ is any directory at any hierarchy within the
`content/` directory, that contains at least an **`_index.md`** file.
@@ -151,7 +150,7 @@ type as a content resource as long as it is a content type recognized by Hugo.
{{% /note %}}
### Examples of Branch Bundle organization {#examples-of-branch-bundle-organization}
### Examples of branch bundle organization
```text
content/

View File

@@ -1,5 +1,5 @@
---
title: Page Resources
title: Page resources
description: Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata.
categories: [content management]
keywords: [bundle,content,resources]
@@ -42,7 +42,7 @@ ResourceType
: The main type of the resource's [Media Type](/templates/output-formats/#media-types). For example, a file of MIME type `image/jpeg` has the ResourceType `image`. A `Page` will have `ResourceType` with value `page`.
Name
: Default value is the filename (relative to the owning page). Can be set in front matter.
: Default value is the file name (relative to the owning page). Can be set in front matter.
Title
: Default value is the same as `.Name`. Can be set in front matter.
@@ -67,21 +67,21 @@ with the contents of the file. Use this to create inline resources.
{{ end }}
{{ with .Resources.GetMatch "img.png" }}
<img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
<img src="data:{{ .MediaType.Type }};base64,{{ .Content | base64Encode }}">
{{ end }}
```
MediaType
: The MIME type of the resource, such as `image/jpeg`.
MediaType.Type
: The media type (formerly known as a MIME type) of the resource (e.g., `image/jpeg`).
MediaType.MainType
: The main type of the resource's MIME type. For example, a file of MIME type `application/pdf` has for MainType `application`.
: The main type of the resource's media type (e.g., `image`).
MediaType.SubType
: The subtype of the resource's MIME type. For example, a file of MIME type `application/pdf` has for SubType `pdf`. Note that this is not the same as the file extension. For example, Microsoft PowerPoint files (`.ppt`) have a subtype of `vnd.ms-powerpoint`.
: The subtype of the resource's type (e.g., `jpeg`). This may or may not correspond to the file suffix.
MediaType.Suffixes
: A slice of possible suffixes for the resource's MIME type.
: A slice of possible file suffixes for the resource's media type (e.g., `[jpg jpeg jpe jif jfif]`).
## Methods
@@ -101,7 +101,7 @@ Match
GetMatch
: Same as `Match` but will return the first match.
### Pattern Matching
### Pattern matching
```go
// Using Match/GetMatch to find this images/sunset.jpg ?
@@ -115,7 +115,7 @@ GetMatch
```
## Page Resources Metadata
## Page resources metadata
The page resources' metadata is managed from the corresponding page's front matter with an array/table parameter named `resources`. You can batch assign values using [wildcards](https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm).

View File

@@ -1,5 +1,5 @@
---
title: Related Content
title: Related content
description: List related content in "See Also" sections.
categories: [content management]
keywords: [content]
@@ -12,9 +12,9 @@ weight: 110
aliases: [/content/related/,/related/]
---
Hugo uses a set of factors to identify a page's related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
Hugo uses a set of factors to identify a page's related content based on front matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
## List Related Content
## 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:
@@ -60,7 +60,7 @@ A fictional example using all of the above options:
We improved and simplified this feature in Hugo 0.111.0. Before this we had 3 different methods: `Related`, `RelatedTo` and `RelatedIndicies`. Now we have only one method: `Related`. The old methods are still available but deprecated. Also see [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature.
{{% /note %}}
## Index Content Headings in Related Content
## Index content headings in related content
{{< new-in "0.111.0" >}}
@@ -105,7 +105,7 @@ weight = 80
{{ end }}
```
## Configure Related Content
## Configure related content
Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed.
@@ -130,10 +130,10 @@ Note that if you have configured `tags` as a taxonomy, `tags` will also be added
Custom configuration should be set using the same syntax.
{{% note %}}
If you add a `related` config section, you need to add a complete configuration. It is not possible to just set, say, `includeNewer` and use the rest from the Hugo defaults.
If you add a `related` configuration section, you need to add a complete configuration. It is not possible to just set, say, `includeNewer` and use the rest from the Hugo defaults.
{{% /note %}}
### Top Level Config Options
### Top level configuration options
threshold
: A value between 0-100. Lower value will give more, but maybe not so relevant, matches.
@@ -144,10 +144,10 @@ includeNewer
toLower
: Set to true to lower case keywords in both the indexes and the queries. This may give more accurate results at a slight performance penalty. Note that this can also be set per index.
### Config Options per Index
### Configuration options per index
name
: The index name. This value maps directly to a page param. Hugo supports string values (`author` in the example) and lists (`tags`, `keywords` etc.) and time and date objects.
: The index name. This value maps directly to a page parameter. Hugo supports string values (`author` in the example) and lists (`tags`, `keywords` etc.) and time and date objects.
type
: {{< new-in "0.111.0" >}}. One of `basic`(default) or `fragments`.
@@ -168,7 +168,7 @@ pattern
toLower
: See above.
## Performance Considerations
## Performance considerations
**Fast is Hugo's middle name** and we would not have released this feature had it not been blistering fast.

View File

@@ -1,6 +1,5 @@
---
title: Content Sections
linkTitle: Sections
title: Sections
description: Hugo generates a **section tree** that matches your content.
categories: [content management]
keywords: [lists,sections,content types,organization]
@@ -31,7 +30,7 @@ A **section** cannot be defined or overridden by a front matter parameter -- it
is strictly derived from the content organization structure.
{{% /note %}}
## Nested Sections
## Nested sections
The sections can be nested as deeply as you need.
@@ -55,7 +54,7 @@ currently always the *root section* only (`/blog/funny-cats/mypost/ => blog`).
If you need a specific template for a sub-section, you need to adjust either the `type` or `layout` in front matter.
{{% /note %}}
## Example: Breadcrumb Navigation
## Example: breadcrumb navigation
With the available [section variables and methods](#section-page-variables-and-methods) you can build powerful navigation. One common example would be a partial to show Breadcrumb navigation:
@@ -74,17 +73,17 @@ With the available [section variables and methods](#section-page-variables-and-m
</nav>
{{< /code >}}
## Section Page Variables and Methods
## Section page variables and methods
Also see [Page Variables](/variables/page/).
{{< readfile file="/content/en/readfiles/sectionvars.md" markdown="true" >}}
## Content Section Lists
## Content section lists
Hugo will automatically create a page for each *root section* that lists all the content in that section. See the documentation on [section templates] for details on customizing the way these pages are rendered.
## Content *Section* vs Content *Type*
## Content *section* vs. content *type*
By default, everything created within a section will use the [content `type`][content type] that matches the *root section* name. For example, Hugo will assume that `posts/post-1.md` has a `posts` content `type`. If you are using an [archetype] for your `posts` section, Hugo will generate front matter according to what it finds in `archetypes/posts.md`.

View File

@@ -13,7 +13,7 @@ aliases: [/extras/shortcodes/]
testparam: "Hugo Rocks!"
---
## What a Shortcode is
## What a shortcode is
Hugo loves Markdown because of its simple content format, but there are times when Markdown falls short. Often, content authors are forced to add raw HTML (e.g., video `<iframe>`'s) to Markdown content. We think this contradicts the beautiful simplicity of Markdown's syntax.
@@ -23,7 +23,7 @@ A shortcode is a simple snippet inside a content file that Hugo will render usin
In addition to cleaner Markdown, shortcodes can be updated any time to reflect new classes, techniques, or standards. At the point of site generation, Hugo shortcodes will easily merge in your changes. You avoid a possibly complicated search and replace operation.
## Use Shortcodes
## Use shortcodes
{{< youtube 2xkNJL4gJ9E >}}
@@ -54,7 +54,7 @@ You can pass multiple lines as parameters to a shortcode by using raw string lit
and a new line with a "quoted string".` */>}}
```
### Shortcodes with Markdown
### Shortcodes with markdown
In Hugo `0.55` we changed how the `%` delimiter works. Shortcodes using the `%` as the outer-most delimiter will now be fully rendered when sent to the content renderer. They can be part of the generated table of contents, footnotes, etc.
@@ -64,7 +64,7 @@ If you want the old behavior, you can put the following line in the start of you
{{ $_hugo_config := `{ "version": 1 }` }}
```
### Shortcodes Without Markdown
### Shortcodes without markdown
The `<` character indicates that the shortcode's inner content does *not* need further rendering. Often shortcodes without Markdown include internal HTML:
@@ -72,11 +72,11 @@ The `<` character indicates that the shortcode's inner content does *not* need f
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
```
### Nested Shortcodes
### Nested shortcodes
You can call shortcodes within other shortcodes by creating your own templates that leverage the `.Parent` variable. `.Parent` allows you to check the context in which the shortcode is being called. See [Shortcode templates][sctemps].
## Use Hugo's Built-in Shortcodes
## Use Hugo's built-in shortcodes
Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your Markdown content clean.
@@ -125,13 +125,13 @@ attr
attrlink
: If the attribution text needs to be hyperlinked, URL of the destination.
#### Example `figure` Input
#### Example `figure` input
{{< code file="figure-input-example.md" >}}
{{</* figure src="elephant.jpg" title=">An elephant at sunset" */>}}
{{</* figure src="elephant.jpg" title="An elephant at sunset" */>}}
{{< /code >}}
#### Example `figure` Output
#### Example `figure` output
```html
<figure>
@@ -254,17 +254,17 @@ Include this in your markdown:
### `param`
Gets a value from the current `Page's` params set in front matter, with a fallback to the site param value. It will log an `ERROR` if the param with the given key could not be found in either.
Gets a value from the current `Page's` parameters set in front matter, with a fallback to the site parameter value. It will log an `ERROR` if the parameter with the given key could not be found in either.
```bash
{{</* param testparam */>}}
```
Since `testparam` is a param defined in front matter of this page with the value `Hugo Rocks!`, the above will print:
Since `testparam` is a parameter defined in front matter of this page with the value `Hugo Rocks!`, the above will print:
{{< param testparam >}}
To access deeply nested params, use "dot syntax", e.g:
To access deeply nested parameters, use "dot syntax", e.g:
```bash
{{</* param "my.nested.param" */>}}
@@ -282,14 +282,14 @@ Read a more extensive description of `ref` and `relref` in the [cross references
`ref` and `relref` take exactly one required parameter of _reference_, quoted and in position `0`.
#### Example `ref` and `relref` Input
#### Example `ref` and `relref` input
```go-html-template
[Neat]({{</* ref "blog/neat.md" */>}})
[Who]({{</* relref "about.md#who" */>}})
```
#### Example `ref` and `relref` Output
#### Example `ref` and `relref` output
Assuming that standard Hugo pretty URLs are turned on.
@@ -350,7 +350,7 @@ The `youtube` shortcode embeds a responsive video player for [YouTube videos]. O
https://www.youtube.com/watch?v=w7Ft2ymGmfc
```
#### Example `youtube` Input
#### Example `youtube` input
Copy the YouTube video ID that follows `v=` in the video's URL and pass it to the `youtube` shortcode:
@@ -371,7 +371,7 @@ For [accessibility reasons](https://dequeuniversity.com/tips/provide-iframe-titl
{{</* youtube id="w7Ft2ymGmfc" title="A New Hugo Site in Under Two Minutes" */>}}
{{< /code >}}
#### Example `youtube` Output
#### Example `youtube` output
Using the preceding `youtube` example, the following HTML will be added to your rendered website's markup:
@@ -379,17 +379,17 @@ Using the preceding `youtube` example, the following HTML will be added to your
{{< youtube id="w7Ft2ymGmfc" autoplay="true" >}}
{{< /code >}}
#### Example `youtube` Display
#### Example `youtube` display
Using the preceding `youtube` example (without `autoplay="true"`), the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your style sheets and surrounding markup. The video is also include in the [Quick Start of the Hugo documentation][quickstart].
{{< youtube w7Ft2ymGmfc >}}
## Privacy Config
## Privacy configuration
To learn how to configure your Hugo site to meet the new EU privacy regulation, see [Hugo and the GDPR].
## Create Custom Shortcodes
## Create custom shortcodes
To learn more about creating custom shortcodes, see the [shortcode template documentation].

View File

@@ -1,6 +1,5 @@
---
title: Static Files
linkTitle: Static Files
title: Static files
description: Files that get served **statically** (as-is, no modification) on the site root.
categories: [content management]
keywords: [source, directories]
@@ -18,7 +17,7 @@ all **static files** (e.g. stylesheets, JavaScript, images). The static files ar
Hugo can be configured to look into a different directory, or even
**multiple directories** for such static files by configuring the
`staticDir` parameter in the [site config]. All the files in all the
`staticDir` parameter in the [site configuration]. All the files in all the
static directories will form a union filesystem.
This union filesystem will be served from your site root. So a file
@@ -65,5 +64,5 @@ Note 2
: The example above is a [multihost setup]. In a regular setup, all
the static directories will be available to all sites.
[site config]: /getting-started/configuration/#all-configuration-settings
[site configuration]: /getting-started/configuration/#all-configuration-settings
[multihost setup]: /content-management/multilingual/#configure-multilingual-multihost

View File

@@ -1,5 +1,5 @@
---
title: Content Summaries
title: Content summaries
linkTitle: Summaries
description: Hugo generates summaries of your content.
categories: [content management]
@@ -15,7 +15,7 @@ aliases: [/content/summaries/,/content-management/content-summaries/]
With the use of the `.Summary` [page variable][pagevariables], Hugo generates summaries of content to use as a short version in summary views.
## Summary Splitting Options
## Summary splitting options
* Automatic Summary Split
* Manual Summary Split
@@ -23,7 +23,7 @@ With the use of the `.Summary` [page variable][pagevariables], Hugo generates su
It is natural to accompany the summary with links to the original content, and a common design pattern is to see this link in the form of a "Read More ..." button. See the `.RelPermalink`, `.Permalink`, and `.Truncated` [page variables][pagevariables].
### Automatic Summary Splitting
### Automatic summary splitting
By default, Hugo automatically takes the first 70 words of your content as its summary and stores it into the `.Summary` page variable for use in your templates. You may customize the summary length by setting `summaryLength` in your [site configuration](/getting-started/configuration/).
@@ -35,7 +35,7 @@ You can customize how HTML tags in the summary are loaded using functions such a
The Hugo-defined summaries are set to use word count calculated by splitting the text by one or more consecutive whitespace characters. If you are creating content in a `CJK` language and want to use Hugo's automatic summary splitting, set `hasCJKLanguage` to `true` in your [site configuration](/getting-started/configuration/).
{{% /note %}}
### Manual Summary Splitting
### Manual summary splitting
Alternatively, you may add the <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider where you want to split the article.
@@ -57,7 +57,7 @@ Cons
Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> exactly; i.e., all lowercase and with no whitespace.
{{% /note %}}
### Front Matter Summary
### Front matter summary
You might want your summary to be something other than the text that starts the article. In this case you can provide a separate summary in the `summary` variable of the article front matter.
@@ -67,7 +67,7 @@ Pros
Cons
: Extra work for content authors as they need to write an entirely separate piece of text as the summary of the article.
## Summary Selection Order
## Summary selection order
Because there are multiple ways in which a summary can be specified it is useful to understand the order of selection Hugo follows when deciding on the text to be returned by `.Summary`. It is as follows:
@@ -79,7 +79,7 @@ Because there are multiple ways in which a summary can be specified it is useful
Hugo uses the _first_ of the above steps that returns text. So if, for example, your article has both `summary` variable in its front matter and a <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider Hugo will use the manual summary split method.
{{% /note %}}
## Example: First 10 Articles with Summaries
## Example: first 10 articles with summaries
You can show content summaries with the following code. You could use the following snippet, for example, in a [section template].

View File

@@ -1,5 +1,5 @@
---
title: Syntax Highlighting
title: Syntax highlighting
description: Hugo comes with really fast syntax highlighting from Chroma.
keywords: [highlighting,chroma,code blocks,syntax]
categories: [content management]
@@ -14,13 +14,13 @@ aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/]
Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast.
## Configure Syntax Highlighter
## Configure syntax highlighter
See [Configure Highlight](/getting-started/configuration-markup#highlight).
## Generate Syntax Highlighter CSS
## Generate syntax highlighter CSS
If you run with `markup.highlight.noClasses=false` in your site config, you need a style sheet.
If you run with `markup.highlight.noClasses=false` in your site configuration, you need a style sheet.
You can generate one with Hugo:
@@ -30,20 +30,20 @@ hugo gen chromastyles --style=monokai > syntax.css
Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles.
## Highlight Shortcode
## Highlight shortcode
Highlighting is carried out via the built-in [`highlight` shortcode](https://gohugo.io/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Highlighting is carried out via the built-in [`highlight` shortcode](/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Options:
* `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. `table` will give copy-and-paste friendly code blocks.
* `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site configuration. `table` will give copy-and-paste friendly code blocks.
* `hl_lines`: lists a set of line numbers or line number ranges to be highlighted.
* `linenostart=199`: starts the line number count from 199.
* `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`;
* `lineanchors`: Configure a prefix for the anchors on line numbers. Will be suffixed with `-`, so linking to the line number 1 with the option `lineanchors=prefix` adds the anchor `prefix-1` to the page.
* `hl_inline` Highlight inside a `<code>` (inline HTML element) tag. Valid values are `true` or `false`. The `code` tag will get a class with name `code-inline`. {{< new-in "0.101.0" >}}
### Example: Highlight Shortcode
### Example: highlight shortcode
```go-html-template
{{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}}
@@ -76,9 +76,9 @@ func GetTitleFunc(style string) func(s string) string {
}
{{< / highlight >}}
## Highlight Hugo/GO Template Code
## Highlight Hugo/Go template code
For highlighting Hugo/GO template code on your page, add `/*` after the opening double curly braces and `*/` before closing curly braces.
For highlighting Hugo/Go template code on your page, add `/*` after the opening double curly braces and `*/` before closing curly braces.
``` go
{{</*/* myshortcode */*/>}}
@@ -90,11 +90,11 @@ Gives this:
{{</* myshortcode */>}}
```
## Highlight Template Func
## Highlight template function
See [Highlight](/functions/highlight/).
## Highlighting in Code Fences
## Highlighting in code fences
Highlighting in code fences is enabled by default.
@@ -132,7 +132,7 @@ func GetTitleFunc(style string) func(s string) string {
The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode), including `linenos=false`, but note the slightly different Markdown attribute syntax.
## List of Chroma Highlighting Languages
## List of Chroma highlighting languages
The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences):

View File

@@ -12,7 +12,7 @@ weight: 150
aliases: [/taxonomies/overview/,/taxonomies/usage/,/indexes/overview/,/doc/indexes/,/extras/indexes]
---
## What is a Taxonomy?
## What is a taxonomy?
Hugo includes support for user-defined groupings of content called **taxonomies**. Taxonomies are classifications of logical relationships between content.
@@ -28,7 +28,7 @@ Value
: a piece of content assigned to a term
## Example Taxonomy: Movie Website
## Example taxonomy: movie website
Let's assume you are making a website about movies. You may want to include the following taxonomies:
@@ -41,7 +41,7 @@ Let's assume you are making a website about movies. You may want to include the
Then, in each of the movies, you would specify terms for each of these taxonomies (i.e., in the [front matter] of each of your movie content files). From these terms, Hugo would automatically create pages for each Actor, Director, Studio, Genre, Year, and Award, with each listing all of the Movies that matched that specific Actor, Director, Studio, Genre, Year, and Award.
### Movie Taxonomy Organization
### Movie taxonomy organization
To continue with the example of a movie site, the following demonstrates content relationships from the perspective of the taxonomy:
@@ -76,11 +76,11 @@ Moonrise Kingdom <- Value
...
```
## Hugo Taxonomy Defaults {#default-taxonomies}
## Default taxonomies
Hugo natively supports taxonomies.
Without adding a single line to your [site config][config] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
Without adding a single line to your [site configuration] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
{{< code-toggle file="hugo" copy=false >}}
[taxonomies]
@@ -88,7 +88,7 @@ Without adding a single line to your [site config][config] file, Hugo will autom
category = "categories"
{{</ code-toggle >}}
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site config][config] to the following:
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site configuration] to the following:
{{< code-toggle file="hugo" copy=false >}}
disableKinds = ["taxonomy","term"]
@@ -96,18 +96,18 @@ disableKinds = ["taxonomy","term"]
{{% page-kinds %}}
### Default Destinations
### Default destinations
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]
* [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
## Configure taxonomies
Custom taxonomies other than the [defaults](#default-taxonomies) must be defined in your [site config][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
Custom taxonomies other than the [defaults](#default-taxonomies) must be defined in your [site configuration] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
### Example: Adding a custom taxonomy named "series"
### Example: adding a custom taxonomy named "series"
{{% note %}}
While adding custom taxonomies, you need to put in the default taxonomies too, _if you want to keep them_.
@@ -120,9 +120,9 @@ While adding custom taxonomies, you need to put in the default taxonomies too, _
series = "series"
{{</ code-toggle >}}
### Example: Removing default taxonomies
### Example: removing default taxonomies
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site config][config].
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site configuration].
{{< code-toggle file="hugo" copy=false >}}
[taxonomies]
@@ -143,7 +143,7 @@ The configuration option `preserveTaxonomyNames` was removed in Hugo 0.55.
You can now use `.Page.Title` on the relevant taxonomy node to get the original value.
{{% /note %}}
## Add Taxonomies to Content
## Add taxonomies to content
Once a taxonomy is defined at the site level, any piece of content can be assigned to it, regardless of [content type] or [content section].
@@ -153,7 +153,7 @@ Assigning content to a taxonomy is done in the [front matter]. Simply create a v
If you would like the ability to quickly generate content files with preconfigured taxonomies or terms, read the docs on [Hugo archetypes](/content-management/archetypes/).
{{% /note %}}
### Example: Front Matter with Taxonomies
### Example: front matter with taxonomies
{{< code-toggle file="content/example.md" fm=true copy=false >}}
title = "Hugo: A fast and flexible static site generator"
@@ -164,13 +164,13 @@ slug = "hugo"
project_url = "https://github.com/gohugoio/hugo"
{{</ code-toggle >}}
## Order Taxonomies
## 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`.
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.
### Example: Taxonomic `weight`
### Example: taxonomic `weight`
{{< code-toggle copy=false >}}
title = "foo"
@@ -186,7 +186,7 @@ By using taxonomic weight, the same piece of content can appear in different pos
Currently taxonomies only support the [default `weight => date` ordering of list content](/templates/lists/#default-weight--date--linktitle--filepath). For more information, see the documentation on [taxonomy templates](/templates/taxonomy-templates/).
{{% /note %}}
## Add custom metadata to a Taxonomy or Term
## Add custom metadata to a taxonomy or term
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
@@ -203,4 +203,4 @@ wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-list-templates
[taxonomy templates]: /templates/taxonomy-templates/
[terms within the taxonomy]: /templates/taxonomy-templates/#taxonomy-terms-templates "See how to order terms associated with a taxonomy"
[config]: /getting-started/configuration/
[configuration]: /getting-started/configuration/

View File

@@ -1,5 +1,5 @@
---
title: Table of Contents
title: Table of contents
description: Hugo can automatically parse Markdown content and create a Table of Contents you can use in your templates.
categories: [content management]
keywords: [table of contents, toc]
@@ -44,7 +44,7 @@ Hugo will take this Markdown and create a table of contents from `## Introductio
The built-in `.TableOfContents` variables outputs a `<nav id="TableOfContents">` element with a child `<ul>`, whose child `<li>` elements begin with appropriate HTML headings. See [the available settings](/getting-started/configuration-markup/#table-of-contents) to configure what heading levels you want to include in TOC.
## Template Example: Basic TOC
## Template example: basic TOC
The following is an example of a very basic [single page template]:
@@ -64,7 +64,7 @@ The following is an example of a very basic [single page template]:
{{ end }}
{{< /code >}}
## Template Example: TOC Partial
## Template example: TOC partial
The following is a [partial template][partials] that adds slightly more logic for page-level control over your table of contents. It assumes you are using a `toc` field in your content's [front matter] that, unless specifically set to `false`, will add a TOC to any page with a `.WordCount` (see [Page Variables][pagevars]) greater than 400. This example also demonstrates how to use [conditionals] in your templating:
@@ -92,7 +92,7 @@ In the header of your content file, specify the AsciiDoc TOC directives necessar
```asciidoc
// <!-- Your front matter up here -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] configuration key
:toclevels: 4
== Introduction

View File

@@ -1,5 +1,5 @@
---
title: Content Types
title: Content types
description: Hugo is built around content organized in sections.
categories: [content management]
keywords: [lists, sections, content types, types, organization]
@@ -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](https://gohugo.io/templates/views) for more.
- Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](/templates/views) for more.
- Determine which [archetype](/content-management/archetypes/) template to use for new content.

View File

@@ -1,5 +1,5 @@
---
title: URL Management
title: URL management
description: Control the structure and appearance of URLs through front matter entries and settings in your site configuration.
categories: [content management]
keywords: [aliases,redirects,permalinks,urls]
@@ -93,7 +93,7 @@ In your site configuration, define a URL pattern for each top-level section. Eac
Front matter `url` values override the URL patterns defined in the `permalinks` section of your site configuration.
[page kind]: https://gohugo.io/templates/section-templates/#page-kinds
[page kind]: /templates/section-templates/#page-kinds
#### Monolingual examples {#permalinks-monolingual-examples}
@@ -271,10 +271,10 @@ Use these tokens when defining the URL pattern. The `date` field in front matter
: the content's slug (or title if no slug is provided in the front matter)
`:slugorfilename`
: the content's slug (or filename if no slug is provided in the front matter)
: the content's slug (or file name if no slug is provided in the front matter)
`:filename`
: the content's filename (without extension)
: the content's file name (without extension)
For time-related values, you can also use the layout string components defined in Go's [time package]. For example:
@@ -383,7 +383,7 @@ In a multilingual site, use a directory-relative alias, or include the language
aliases = ['/de/posts/previous-file-name']
{{< /code-toggle >}}
### How Aliases Work
### How aliases work
Using the first example above, Hugo generates the following site structure: