Merge commit '8d9511a08f14260cbfb73119e4afae50e5a9966d'

This commit is contained in:
Bjørn Erik Pedersen 2021-12-08 08:54:25 +01:00
commit 6c841a691e
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
48 changed files with 463 additions and 465 deletions

View file

@ -65,7 +65,7 @@ audio
: an array of paths to audio files related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:audio`.
cascade
: a map of Front Matter keys whose values are passed down to the page's descendents unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details.
: a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details.
date
: the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behaviour is configurable.
@ -128,8 +128,7 @@ type
: the type of the content; this value will be automatically derived from the directory (i.e., the [section][]) if not specified in front matter.
url
: the full path to the content from the web root. It makes no assumptions about the path of the content file. It also ignores any language prefixes of
the multilingual feature.
: the full path to the content from the web root. It makes no assumptions about the path of the content file. See [URL Management](/content-management/urls/#set-url-in-front-matter).
videos
: an array of paths to videos related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:video`.
@ -157,7 +156,7 @@ show_comments: false
## Front Matter Cascade
Any node or section can pass down to descendents 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
@ -202,9 +201,9 @@ cascade:
banner: images/typewriter.jpg
{{</ code-toggle >}}
With the above example the Blog section page and its descendents will return `images/typewriter.jpg` when `.Params.banner` is invoked unless:
With the above example the Blog section page and its descendants will return `images/typewriter.jpg` when `.Params.banner` is invoked unless:
- Said descendent has its own `banner` value set
- Said descendant has its own `banner` value set
- Or a closer ancestor node has its own `cascade.banner` value set.

View file

@ -229,7 +229,7 @@ See https://github.com/disintegration/imaging for more. If you want to trade qua
By default the images is encoded in the source format, but you can set the target format as an option.
Valid values are `jpg`, `png`, `tif`, `bmp`, `gif` and `webp`.
Valid values are `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, and `webp`.
```go
{{ $image.Resize "600x jpg" }}

View file

@ -12,7 +12,7 @@ menu:
docs:
parent: "content-management"
weight: 120
weight: 120 #rem
weight: 120
aliases: [/extras/menus/]
toc: true
---
@ -48,31 +48,24 @@ If all you need to do is add an entry to a menu, the simple form works well.
#### A Single Menu
```
---
{{< code-toggle >}}
menu: "main"
---
```
{{< /code-toggle >}}
#### Multiple Menus
```
---
{{< code-toggle >}}
menu: ["main", "footer"]
---
```
{{< /code-toggle >}}
#### Advanced
```
---
{{< code-toggle >}}
menu:
docs:
parent: 'extras'
weight: 20
---
```
{{< /code-toggle >}}
## Add Non-content Entries to a Menu
@ -130,7 +123,6 @@ A common use case is to define a custom param to add a css class to a specific m
class = "highlight-menu-item"
{{</ code-toggle >}}
## Render Menus
See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates.

View file

@ -19,7 +19,7 @@ toc: true
You should define the available languages in a `languages` section in your site configuration.
> Also See [Hugo Multilingual Part 1: Content translation](https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/)
> Also See [Hugo Multilingual Part 1: Content translation]
## Configure Languages
@ -63,7 +63,7 @@ Anything not defined in a `languages` block will fall back to the global value f
With the configuration above, all content, sitemap, RSS feeds, paginations,
and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French.
When working with front matter `Params` in [single page templates][singles], omit the `params` in the key for the translation.
When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation.
`defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`.
@ -83,25 +83,24 @@ disableLanguages = ["fr", "ja"]
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](/getting-started/configuration/#configure-with-environment-variables):
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 `config.toml`, you can enable them in development like this:
```bash
HUGO_DISABLELANGUAGES=" " hugo server
```
### 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.
This means that you can now configure a `baseURL` per `language`:
> If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different.
Example:
@ -123,7 +122,7 @@ title = "In English"
With the above, the two sites will be generated into `public` with their own root:
```bash
```text
public
├── en
└── fr
@ -133,7 +132,7 @@ public
When you run `hugo server` we will start multiple HTTP servers. You will typically see something like this in the console:
```bash
```text
Web Server is available at 127.0.0.1:1313 (bind address 127.0.0.1)
Web Server is available at 127.0.0.1:1314 (bind address 127.0.0.1)
Press Ctrl+C to stop
@ -145,7 +144,6 @@ Live reload and `--navigateToChanged` between the servers work as expected.
Taxonomies and [Blackfriday configuration][config] can also be set per language:
{{< code-toggle file="config" >}}
[Taxonomies]
tag = "tags"
@ -195,7 +193,6 @@ If a file has no language code, it will be assigned the default language.
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param.
{{< code-toggle file="config" >}}
languages:
en:
weight: 10
@ -205,7 +202,6 @@ languages:
weight: 20
languageName: "Français"
contentDir: "content/french"
{{< /code-toggle >}}
The value of `contentDir` can be any valid path -- even absolute path references. The only restriction is that the content directories cannot overlap.
@ -222,7 +218,7 @@ Their language is __assigned__ according to the content directory they are __pla
By having the same **path and basename** (relative to their language content directory), the content pieces are __linked__ together as translated pages.
### Bypassing default linking.
### Bypassing default linking
Any pages sharing the same `translationKey` set in front matter will be linked as translated pages regardless of basename or location.
@ -232,14 +228,12 @@ Considering the following example:
2. `/content/om.nn.md`
3. `/content/presentation/a-propos.fr.md`
```yaml
# set in all three pages
{{< code-toggle >}}
translationKey: "about"
```
{{< /code-toggle >}}
By setting the `translationKey` front matter param 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).
@ -253,7 +247,6 @@ Title: A Propos
slug: "a-propos"
{{< /code-toggle >}}
At render, Hugo will build both `/about/` and `/fr/a-propos/` while maintaining their translation linking.
{{% note %}}
@ -292,7 +285,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, 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 also uses the [`i18n` function][i18func] described in the next section.
@ -300,7 +293,6 @@ The above also uses the [`i18n` function][i18func] described in the next section
`.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:
{{< code file="layouts/partials/allLanguages.html" >}}
<ul>
{{ range $.Site.Home.AllTranslations }}
@ -311,22 +303,24 @@ The above also uses the [`i18n` function][i18func] described in the next section
## 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.
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.
Translations are collected from the `themes/<THEME>/i18n/` folder (built into the theme), as well as translations present in `i18n/` at the root of your project. In the `i18n`, the translations will be merged and take precedence over what is in the theme folder. Language files should be named according to [RFC 5646][] with names such as `en-US.toml`, `fr.toml`, etc.
Translations are collected from the `themes/<THEME>/i18n/` folder (built into the theme), as well as translations present in `i18n/` at the root of your project. In the `i18n`, the translations will be merged and take precedence over what is in the theme folder. Language files should be named according to [RFC 5646] with names such as `en-US.toml`, `fr.toml`, etc.
{{% note %}}
From **Hugo 0.31** you no longer need to use a valid language code. It can be anything.
Artificial languages with private use subtags as defined in [RFC 5646 &#167; 2.2.7](https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7) are also supported. You may omit the `art-x-` prefix for brevity. For example:
See https://github.com/gohugoio/hugo/issues/3564
```text
art-x-hugolang
hugolang
```
{{% /note %}}
Private use subtags must not exceed 8 alphanumeric characters.
### Query basic translation
From within your templates, use the `i18n` function like this:
```
```go-html-template
{{ i18n "home" }}
```
@ -339,7 +333,7 @@ other = "Home"
The result will be
```
```text
Home
```
@ -347,7 +341,7 @@ Home
Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`:
```
```go-html-template
{{ i18n "wordCount" . }}
```
@ -360,7 +354,7 @@ other = "This article has {{ .WordCount }} words."
Assume `.WordCount` in the context has value is 101. The result will be:
```
```text
This article has 101 words.
```
@ -368,7 +362,7 @@ This article has 101 words.
In order to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property.
```
```go-html-template
{{ i18n "readingTime" .ReadingTime }}
```
@ -382,52 +376,122 @@ other = "{{.Count}} minutes to read"
Assume `.ReadingTime.Count` in the context has value of 525600. The result will be:
```
```text
525600 minutes to read
```
If `.ReadingTime.Count` in the context has value is 1. The result is:
```
```text
One minute to read
```
In case you need to pass custom data: (`(dict "Count" 25)` is minimum requirement)
```
```go-html-template
{{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }}
```
## Localization
## Customize Dates
The following localization examples assume your site's primary language is English, with translations to French and German.
At the time of this writing, Go does not yet have support for internationalized locales for dates, but if you do some work, you can simulate it. For example, if you want to use French month names, you can add a data file like ``data/mois.yaml`` with this content:
{{< code-toggle file="config" >}}
defaultContentLang = 'en'
~~~yaml
1: "janvier"
2: "février"
3: "mars"
4: "avril"
5: "mai"
6: "juin"
7: "juillet"
8: "août"
9: "septembre"
10: "octobre"
11: "novembre"
12: "décembre"
~~~
[languages]
[languages.en]
contentDir = 'content/en'
languageName = 'English'
weight = 1
[languages.fr]
contentDir = 'content/fr'
languageName = 'Français'
weight = 2
[languages.de]
contentDir = 'content/de'
languageName = 'Deutsch'
weight = 3
...then index the non-English date names in your templates like so:
{{< /code-toggle >}}
~~~html
<time class="post-date" datetime="{{ .Date.Format `2006-01-02T15:04:05Z07:00` | safeHTML }}">
Article publié le {{ .Date.Day }} {{ index $.Site.Data.mois (printf "%d" .Date.Month) }} {{ .Date.Year }} (dernière modification le {{ .Lastmod.Day }} {{ index $.Site.Data.mois (printf "%d" .Lastmod.Month) }} {{ .Lastmod.Year }})
</time>
~~~
### Dates
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file.
With this front matter:
{{< code-toggle >}}
date = 2021-11-03T12:34:56+01:00
{{< /code-toggle >}}
And this template code:
```go-html-template
{{ .Date | time.Format ":date_full" }}
```
The rendered page displays:
Language|Value
:--|:--
English|Wednesday, November 3, 2021
Français|mercredi 3 novembre 2021
Deutsch|Mittwoch, 3. November 2021
See [time.Format] for details.
### Currency
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatCurrency 2 "USD" }}
```
The rendered page displays:
Language|Value
:--|:--
English|$512.50
Français|512,50 $US
Deutsch|512,50 $
See [lang.FormatCurrency] and [lang.FormatAccounting] for details.
### Numbers
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatNumber 2 }}
```
The rendered page displays:
Language|Value
:--|:--
English|512.50
Français|512,50
Deutsch|512,50
See [lang.FormatNumber] and [lang.FormatNumberCustom] for details.
### Percentages
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatPercent 2 }} ---> 512.50%
```
The rendered page displays:
Language|Value
:--|:--
English|512.50%
Français|512,50 %
Deutsch|512,50 %
See [lang.FormatPercent] for details.
## Menus
@ -445,7 +509,6 @@ url = "/"
name = "Home"
weight = 0
[languages.de]
weight = 10
languageName = "Deutsch"
@ -458,7 +521,7 @@ weight = 0
The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu in the current language. Note that `absLangURL` below will link to the correct locale of your website. Without it, menu entries in all languages would link to the English version, since it's the default content language that resides in the root directory.
```
```go-html-template
<ul>
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
@ -467,7 +530,6 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
</li>
{{- end }}
</ul>
```
## Missing Translations
@ -480,12 +542,12 @@ While translating a Hugo website, it can be handy to have a visual indicator of
Hugo will generate your website with these missing translation placeholders. It might not be suitable for production environments.
{{% /note %}}
For merging of content from other languages (i.e. missing content translations), see [lang.Merge](/functions/lang.merge/).
For merging of content from other languages (i.e. missing content translations), see [lang.Merge].
To track down missing translation strings, run Hugo with the `--i18n-warnings` flag:
```
hugo --i18n-warnings | grep i18n
```bash
hugo --i18n-warnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount
```
@ -504,8 +566,17 @@ If there is more than one language defined, the `LanguagePrefix` variable will e
[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/i18n/
[lang.FormatAccounting]: /functions/lang/#langformataccounting
[lang.FormatCurrency]: /functions/lang/#langformatcurrency
[lang.FormatNumber]: /functions/lang/#langformatnumber
[lang.FormatNumberCustom]: functions/lang/#langformatnumbercustom
[lang.FormatPercent]: /functions/lang/#langformatpercent
[lang.Merge]: /functions/lang.merge/
[menus]: /content-management/menus/
[OS environment]: /getting-started/configuration/#configure-with-environment-variables
[rellangurl]: /functions/rellangurl
[RFC 5646]: https://tools.ietf.org/html/rfc5646
[singles]: /templates/single-page-templates/
[single page templates]: /templates/single-page-templates/
[time.Format]: /functions/dateformat

View file

@ -24,12 +24,12 @@ Hugo `0.32` announced page-relative images and other resources packaged into `Pa
These terms are connected, and you also need to read about [Page Resources]({{< relref "/content-management/page-resources" >}}) and [Image Processing]({{< relref "/content-management/image-processing" >}}) to get the full picture.
{{< imgproc 1-featured Resize "300x" >}}
The illustration shows 3 bundles. Note that the home page bundle cannot contain other content pages, but other files (images etc.) are fine.
The illustration shows three bundles. Note that the home page bundle cannot contain other content pages, although other files (images etc.) are allowed.
{{< /imgproc >}}
{{% note %}}
The bundle documentation is **work in progress**. We will publish more comprehensive docs about this soon.
The bundle documentation is a **work in progress**. We will publish more comprehensive docs about this soon.
{{% /note %}}
@ -40,7 +40,7 @@ In Hugo, your content should be organized in a manner that reflects the rendered
While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][].
Without any additional configuration, the following will just work:
Without any additional configuration, the following will automatically work:
```
.
@ -70,7 +70,7 @@ The following demonstrates the relationships between your content organization a
**Tip:** You can get a reference to the content and metadata in `_index.md` using the [`.Site.GetPage` function](/functions/getpage/).
{{% /note %}}
You can keep 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 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:
```
@ -96,12 +96,12 @@ At build, this will output to the following destination with the associated valu
https://example.com/posts/index.html
```
The [sections][] can be nested as deeply as you need. The important part to understand is, that to make the section tree fully navigational, at least the lower-most section needs a content file. (i.e. `_index.md`).
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 content files in each of your sections are going to 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 as [single page templates][singles]. Here is an example of a single `post` within `posts`:
```
@ -112,7 +112,7 @@ Single content files in each of your sections are going to be rendered as [singl
content/posts/my-first-hugo-post.md
```
When Hugo builds your site, the content will be outputted to the following destination:
When Hugo builds your site, the content will be output to the following destination:
```
@ -128,11 +128,11 @@ https://example.com/posts/my-first-hugo-post/index.html
## Paths Explained
The following concepts will provide more insight into the relationship between your project's organization and the default behaviors of Hugo when building the output website.
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.
### `section`
A default content type is determined by a piece of content's section. `section` is determined by the location within the project's `content` directory. `section` *cannot* be specified or overridden in front matter.
A default content type is determined by the section in which a content item is stored. `section` is determined by the location within the project's `content` directory. `section` *cannot* be specified or overridden in front matter.
### `slug`
@ -152,24 +152,24 @@ A content's `path` is determined by the section's path to the file. The file `pa
The `url` is the relative URL for the piece of content. The `url`
* is based on the content's location within the directory structure OR
* is defined in front matter and *overrides all the above*
* is based on the content item's location within the directory structure OR
* is defined in front matter, in which case it *overrides all the above*
## Override Destination Paths via Front Matter
Hugo believes that you organize your content with a purpose. The same structure that works to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored in the destination.
Hugo assumes that your content is organized with a purpose. The same structure that you use to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored at the destination.
There are times where you may need more control over your content. In these cases, there are fields that can be specified in the front matter to determine the destination of a specific piece of content.
There are times when you may need more fine-grained control over the content organization. In such cases, the front matter field can be used to determine the destination of a specific piece of content.
The following items are defined in this order for a specific reason: items explained further down in the list will override earlier items, and not all of these items can be defined in front matter:
The following items are defined in a specific order for a reason: items explained lower down in the list override higher items. Note that not all items can be defined in front matter.
### `filename`
This isn't in the front matter, but is the actual name of the file minus the extension. This will be the name of the file in the destination (e.g., `content/posts/my-post.md` becomes `example.com/posts/my-post/`).
`filename` is not a front matter field. It is the actual file name, minus the extension. This will be the name of the file in the destination (e.g., `content/posts/my-post.md` becomes `example.com/posts/my-post/`).
### `slug`
When defined in the front matter, the `slug` can take the place of the filename for the destination.
When defined in the front matter, the `slug` can take the place of the filename in the destination.
{{< code file="content/posts/old-post.md" >}}
---
@ -186,11 +186,11 @@ example.com/posts/new-post/
### `section`
`section` is determined by a content's location on disk and *cannot* be specified in the front matter. See [sections][] for more information.
`section` is determined by a content item's location on disk and *cannot* be specified in the front matter. See [sections] for more information.
### `type`
A content's `type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [types][]. This can come in especially handy when you want a piece of content to render using a different layout. In the following example, you can create a layout at `layouts/new/mylayout.html` that Hugo will use to render this piece of content, even in the midst of many other posts.
A content item's `type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [types]. This can come in especially handy when you want a piece of content to render using a different layout. In the following example, you can create a layout at `layouts/new/mylayout.html` that Hugo will use to render this piece of content, even in the midst of many other posts.
{{< code file="content/posts/my-post.md" >}}
---
@ -206,7 +206,7 @@ layout: mylayout
### `url`
A complete URL can be provided. This will override all the above as it pertains to the end destination. This must be the path from the baseURL (starting with a `/`). `url` will be used exactly as it provided in the front matter and will ignore the `--uglyURLs` setting in your site configuration:
A complete URL can be provided. This will override all the above as it pertains to the end destination. This must be the path from the baseURL (starting with a `/`). `url` will be used exactly as it is defined in the front matter, and will ignore the `--uglyURLs` setting in your site configuration:
{{< code file="content/posts/old-url.md" >}}
---

View file

@ -60,7 +60,22 @@ RelPermalink
: The relative URL to the resource. Resources of type `page` will have no value.
Content
: The content of the resource itself. For most resources, this returns a string with the contents of the file. This can be used to inline some resources, such as `<script>{{ (.Resources.GetMatch "myscript.js").Content | safeJS }}</script>` or `<img src="{{ (.Resources.GetMatch "mylogo.png").Content | base64Encode }}">`.
: The content of the resource itself. For most resources, this returns a string
with the contents of the file. Use this to create inline resources.
```go-html-template
{{ with .Resources.GetMatch "script.js" }}
<script>{{ .Content | safeJS }}</script>
{{ end }}
{{ with .Resources.GetMatch "style.css" }}
<style>{{ .Content | safeCSS }}</style>
{{ end }}
{{ with .Resources.GetMatch "img.png" }}
<img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
{{ end }}
```
MediaType
: The MIME type of the resource, such as `image/jpeg`.

View file

@ -154,7 +154,7 @@ go install
Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it:
```
go get github.com/magefile/mage
go install github.com/magefile/mage@latest
```
### Fork the repository

View file

@ -20,7 +20,7 @@ aliases: []
`.GetPage` returns a page of a given `path`. Both `Site` and `Page` implements this method. The `Page` variant will, if given a relative path -- i.e. a path without a leading `/` -- try look for the page relative to the current page.
{{% note %}}
**Note:** We overhauled and simplified the `.GetPage` API in Hugo 0.45. Before that you needed to provide a `Kind` attribute in addition to the path, e.g. `{{ .Site.GetPage "section" "blog" }}`. This will still work, but is now superflous.
**Note:** We overhauled and simplified the `.GetPage` API in Hugo 0.45. Before that you needed to provide a `Kind` attribute in addition to the path, e.g. `{{ .Site.GetPage "section" "blog" }}`. This will still work, but is now superfluous.
{{% /note %}}
@ -28,7 +28,7 @@ aliases: []
{{ with .Site.GetPage "/blog" }}{{ .Title }}{{ end }}
```
This method wil return `nil` when no page could be found, so the above will not print anything if the blog section is not found.
This method will return `nil` when no page could be found, so the above will not print anything if the blog section is not found.
To find a regular page in the blog section::

View file

@ -19,7 +19,7 @@ aliases: []
`dict` is especially useful for passing more than one value to a partial template.
Note that the `key` can be either a `string` or a `string slice`. The latter is useful to create a deply nested structure, e.g.:
Note that the `key` can be either a `string` or a `string slice`. The latter is useful to create a deeply nested structure, e.g.:
```go-text-template
{{ $m := dict (slice "a" "b" "c") "value" }}

View file

@ -2,27 +2,41 @@
title: "fileExists"
linktitle: "fileExists"
date: 2017-08-31T22:38:22+02:00
description: Checks whether a file exists under the given path.
description: Checks for file or directory existence.
publishdate: 2017-08-31T22:38:22+02:00
lastmod: 2017-08-31T22:38:22+02:00
lastmod: 2021-11-26
categories: [functions]
menu:
docs:
parent: "functions"
signature: ["fileExists PATH"]
signature: ["os.FileExists PATH","fileExists PATH"]
workson: []
hugoversion:
relatedfuncs: []
relatedfuncs: ['os.ReadDir','os.ReadFile','os.Stat']
deprecated: false
aliases: []
---
The `os.FileExists` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
`fileExists` allows you to check if a file exists under a given path, e.g. before inserting code into a template:
With this directory structure:
```
{{ if (fileExists "static/img/banner.jpg") -}}
<img src="{{ "img/banner.jpg" | absURL }}" />
{{- end }}
```text
content/
├── about.md
├── contact.md
└── news/
├── article-1.md
└── article-2.md
```
In the example above, a banner from the `static` folder should be shown if the given path points to an existing file.
The function returns these values:
```go-html-template
{{ os.FileExists "content" }} --> true
{{ os.FileExists "content/news" }} --> true
{{ os.FileExists "content/news/article-1" }} --> false
{{ os.FileExists "content/news/article-1.md" }} --> true
{{ os.FileExists "news" }} --> true
{{ os.FileExists "news/article-1" }} --> false
{{ os.FileExists "news/article-1.md" }} --> true
```

View file

@ -1,30 +1,43 @@
---
title: getenv
description: Returns the value of an environment variable.
description: Returns the value of an environment variable, or an empty string if the environment variable is not set.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
lastmod: 2021-11-26
categories: [functions]
menu:
docs:
parent: "functions"
keywords: []
signature: ["getenv VARIABLE"]
signature: ["os.Getenv VARIABLE", "getenv VARIABLE"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
aliases: []
---
Examples:
Takes a string containing the name of the variable as input. Returns
an empty string if the variable is not set, otherwise returns the
value of the variable.
```
{{ getenv "HOME" }}
```go-html-template
{{ os.Getenv "HOME" }} --> /home/victor
{{ os.Getenv "USER" }} --> victor
```
{{% note %}}
In Unix-like environments, the variable must also be exported in order to be seen by `hugo`.
{{% /note %}}
You can pass values when building your site:
```bash
MY_VAR1=foo MY_VAR2=bar hugo
OR
export MY_VAR1=foo
export MY_VAR2=bar
hugo
```
And then retrieve the values within a template:
```go-html-template
{{ os.Getenv "MY_VAR1" }} --> foo
{{ os.Getenv "MY_VAR2" }} --> bar
```

View file

@ -1,9 +1,9 @@
---
title: os.Stat
description: Gets a file information of a given path.
description: Returns a FileInfo structure describing a file or directory.
date: 2018-08-07
publishdate: 2018-08-07
lastmod: 2018-08-07
lastmod: 2021-11-26
categories: [functions]
menu:
docs:
@ -12,21 +12,21 @@ keywords: [files]
signature: ["os.Stat PATH"]
workson: []
hugoversion:
relatedfuncs: [readDir]
relatedfuncs: ['os.FileExists','os.ReadDir','os.ReadFile']
deprecated: false
aliases: []
---
The `os.Stat` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
If your current project working directory has a single file named `README.txt` (30 bytes):
```
{{ $stat := os.Stat "README.txt" }}
{{ $stat.Name }} → "README.txt"
{{ $stat.Size }} → 30
```go-html-template
{{ $f := os.Stat "README.md" }}
{{ $f.IsDir }} --> false (bool)
{{ $f.ModTime }} --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time)
{{ $f.Name }} --> README.md (string)
{{ $f.Size }} --> 241 (int64)
{{ $d := os.Stat "content" }}
{{ $d.IsDir }} --> true (bool)
```
Function [`os.Stat`][Stat] returns [`os.FileInfo`][osfileinfo].
For further information of `os.FileInfo`, see [golang page][osfileinfo].
[Stat]: /functions/os.Stat/
[osfileinfo]: https://golang.org/pkg/os/#FileInfo
Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo).

View file

@ -1,28 +1,51 @@
---
title: readDir
description: Gets a directory listing from a directory relative to the current working directory.
date: 2017-02-01
description: Returns an array of FileInfo structures sorted by filename, one element for each directory entry.
publishdate: 2017-02-01
lastmod: 2017-02-01
lastmod: 2021-11-26
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [files]
signature: ["readDir PATH"]
signature: ["os.ReadDir PATH", "readDir PATH"]
workson: []
hugoversion:
relatedfuncs: [readFile]
relatedfuncs: ['os.FileExists','os.ReadFile','os.Stat']
deprecated: false
aliases: []
---
The `os.ReadDir` function resolves the path relative to the root of your project directory. A leading path separator (`/`) is optional.
If your current project working directory has a single file named `README.txt`:
With this directory structure:
```
{{ range (readDir ".") }}{{ .Name }}{{ end }} → "README.txt"
```text
content/
├── about.md
├── contact.md
└── news/
├── article-1.md
└── article-2.md
```
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates][local].
This template code:
[local]: /templates/files/
```go-html-template
{{ range os.ReadDir "content" }}
{{ .Name }} --> {{ .IsDir }}
{{ end }}
```
Produces:
```html
about.md --> false
contact.md --> false
news --> true
```
Note that `os.ReadDir` is not recursive.
Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo).
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates]({{< relref "/templates/files" >}}).

View file

@ -1,32 +1,41 @@
---
title: readFile
description: Reads a file from disk relative to the current project working directory and returns a string.
description: Returns the contents of a file.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-04-30
lastmod: 2021-11-26
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [files]
signature: ["readFile PATH"]
signature: ["os.ReadFile PATH", "readFile PATH"]
workson: []
hugoversion:
relatedfuncs: [readDir]
relatedfuncs: ['os.FileExists','os.ReadDir','os.Stat']
deprecated: false
aliases: []
---
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
Note that the filename must be relative to the current project working directory, or the project's `/content` folder.
With a file named README.md in the root of your project directory:
So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`:
```
{{readFile "README.txt"}} → "Hugo Rocks!"
```text
This is **bold** text.
```
If you receive a "file doesn't exist" error with a path listed, do take note that the path is the last one checked by the function, and may not accurately reflect your target. You should generally double-check your path for mistakes.
This template code:
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates][local].
```go-html-template
{{ os.ReadFile "README.md" }}
```
[local]: /templates/files/
Produces:
```html
This is **bold** text.
```
Note that `os.ReadFile` returns raw (uninterpreted) content.
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates]({{< relref "/templates/files" >}}).

View file

@ -22,7 +22,7 @@ It normally takes two parameters: `start` and `length`. It can also take one par
To extract characters from the end of the string, use a negative start number.
In addition, borrowing from the extended behavior described at https://php.net substr, if `length` is given and is negative, that number of characters will be omitted from the end of string.
If `length` is given and is negative, that number of characters will be omitted from the end of string.
```
{{ substr "abcdef" 0 }} → "abcdef"

View file

@ -1,35 +1,31 @@
---
title: .Unix
draft: false
description: .Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC.
description: Converts a time.Time value to the number of seconds elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00&nbsp;UTC on 1 January 1970.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
keywords: [dates,time]
categories: [functions]
menu:
docs:
parent: "functions"
signature: [".Unix"]
workson: [times]
hugoversion:
signature: [".Unix",".UnixMilli",".UnixMicro",".UnixNano"]
relatedfuncs: [Format,dateFormat,now,time]
deprecated: false
aliases: []
---
## Example: Time Passed Since Last Modification
The `Milli`, `Micro`, and `Nano` variants return the number of milliseconds, microseconds, and nanoseconds (respectively) elapsed since the Unix epoch.
This very simple one-liner uses `now.Unix` to calculate the amount of time that has passed between the `.LastMod` for the current page and the last build of the current page.
```go-html-template
.Date.Unix --> 1637259694
.ExpiryDate.Unix --> 1672559999
.Lastmod.Unix --> 1637361786
.PublishDate.Unix --> 1637421261
{{< code file="time-passed.html" >}}
{{ div (sub now.Unix .Lastmod.Unix) 86400 }}
{{< /code >}}
("1970-01-01T00:00:00-00:00" | time.AsTime).Unix --> 0
("1970-01-01T00:00:42-00:00" | time.AsTime).Unix --> 42
("1970-04-11T01:48:29-08:00" | time.AsTime).Unix --> 8675309
("2026-05-02T20:09:31-07:00" | time.AsTime).Unix --> 1777777771
Since both values are integers, they can be subtracted and then divided by the number of seconds in a day (i.e., `60 * 60 * 24 == 86400`).
{{% note %}}
Hugo's output is *static*. For the example above to be realistic, the site needs to be built every day.
{{% /note %}}
[partial template]: /templates/partials/
now.Unix --> 1637447841
now.UnixMilli --> 1637447841347
now.UnixMicro --> 1637447841347378
now.UnixNano --> 1637447841347378799
```

View file

@ -1,79 +0,0 @@
---
title: Code Toggle
description: Code Toggle tryout and showcase.
date: 2018-03-16
categories: [getting started,fundamentals]
keywords: [configuration,toml,yaml,json]
weight: 60
sections_weight: 60
draft: false
toc: true
---
## The Config Toggler!
This is an example for the Config Toggle shortcode.
Its purpose is to let users choose a Config language by clicking on its corresponding tab. Upon doing so, every Code toggler on the page will be switched to the target language. Also, target language will be saved in user's `localStorage` so when they go to a different pages, Code Toggler display their last "toggled" config language.
{{% note %}}
The `code-toggler` shortcode is not an internal Hugo shortcode. This page's purpose is to test out a custom feature that we use throughout this site. See: https://github.com/gohugoio/gohugoioTheme/blob/master/layouts/shortcodes/code-toggle.html
{{% /note %}}
## That Config Toggler
{{< code-toggle file="config">}}
baseURL: "https://yoursite.example.com/"
title: "My Hugo Site"
footnoteReturnLinkContents: "↩"
permalinks:
posts: /:year/:month/:title/
params:
Subtitle: "Hugo is Absurdly Fast!"
AuthorName: "Jon Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
{{< /code-toggle >}}
## Another Config Toggler!
{{< code-toggle file="theme">}}
# theme.toml template for a Hugo theme
name = "Hugo Theme"
license = "MIT"
licenselink = "https://github.com/budparr/gohugo.io/blob/master/LICENSE.md"
description = ""
homepage = "https://github.com/budparr/gohugo.io"
tags = ["website"]
features = ["", ""]
min_version = 0.18
[author]
name = "Bud Parr"
homepage = "https://github.com/budparr"
{{< /code-toggle >}}
## Two regular code blocks
{{< code file="bf-config.toml" >}}
[blackfriday]
angledQuotes = true
fractions = false
plainIDAnchors = true
extensions = ["hardLineBreak"]
{{< /code >}}
{{< code file="bf-config.yml" >}}
blackfriday:
angledQuotes: true
fractions: false
plainIDAnchors: true
extensions:
- hardLineBreak
{{< /code >}}

View file

@ -166,6 +166,12 @@ Enable to turn relative URLs into absolute.
The directory from where Hugo reads content files. {{% module-mounts-note %}}
### copyright
**Default value:** ""
Copyright notice for your site, typically displayed in the footer.
### dataDir
**Default value:** "data"
@ -275,6 +281,12 @@ If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will
### imaging
See [Image Processing Config](/content-management/image-processing/#image-processing-config).
### languageCode
**Default value:** ""
A language tag as defined by [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646). The internal [RSS template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml) populates its `<language>` element with this value. The value is not used elsewhere.
### languages
See [Configure Languages](/content-management/multilingual/#configure-languages).
@ -351,6 +363,17 @@ When using `ref` or `relref` to resolve page links and a link cannot resolved, i
### refLinksNotFoundURL
URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is.
### removePathAccents
**Default value:** false
Removes [non-spacing marks](https://www.compart.com/en/unicode/category/Mn) from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character) in content paths.
```text
content/post/hügó.md --> https://example.org/post/hugo/
```
### rssLimit
Maximum number of items in the RSS feed.
@ -381,9 +404,9 @@ The directory where Hugo reads the themes from.
### timeout
**Default value:** 10000
**Default value:** "30s"
Timeout for generating page contents, in milliseconds (defaults to 10&nbsp;seconds). *Note:* this is used to bail out of recursive content generation, if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents) you might need to raise this limit.
Timeout for generating page contents, specified as a [duration](https://pkg.go.dev/time#Duration) or in milliseconds. *Note:*&nbsp;this is used to bail out of recursive content generation. You might need to raise this limit if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents).
### timeZone
@ -456,7 +479,7 @@ This is only relevant when running `hugo server`, and it allows to set HTTP head
{{< code-toggle file="config">}}
[server]
[[server.headers]]
for = "/**.html"
for = "/**"
[server.headers.values]
X-Frame-Options = "DENY"
@ -471,7 +494,7 @@ Since this is is "development only", it may make sense to put it below the `deve
{{< code-toggle file="config/development/server">}}
[[headers]]
for = "/**.html"
for = "/**"
[headers.values]
X-Frame-Options = "DENY"
@ -564,12 +587,18 @@ Test and document setting params via JSON env var.
## Ignore Content and Data Files when Rendering
To exclude specific files from the content and data directories when rendering your site, set `ignoreFiles` to one or more regular expressions.
To exclude specific files from the `content` and `data` directories when rendering your site, set `ignoreFiles` to one or more regular expressions to match against the absolute file path.
For example, to ignore content and data files ending with `.foo` and `.boo`:
To ignore files ending with `.foo` or `.boo`:
{{< code-toggle >}}
ignoreFiles = [ "\\.foo$","\\.boo$"]
{{< code-toggle copy="false" >}}
ignoreFiles = ['\.foo$', '\.boo$']
{{< /code-toggle >}}
To ignore a file using the absolute file path:
{{< code-toggle copy="false" >}}
ignoreFiles = ['^/home/user/project/content/test\.md$']
{{< /code-toggle >}}
## Configure Front Matter

View file

@ -516,6 +516,14 @@ For the latest version, the Hugo package maintained by [@daftaupe](https://githu
See the [related discussion in the Hugo forums][redhatforum].
### openSUSE Tumbleweed
openSUSE maintains an [official package](https://software.opensuse.org/package/hugo) for the Tumbleweed rolling release distribution, it may be installed with:
````
sudo zypper install hugo
````
### Solus
Solus includes Hugo in its package repository, it may be installed with:

View file

@ -86,6 +86,14 @@ jobs:
For more advanced settings [actions-hugo](https://github.com/marketplace/actions/hugo-setup) and [actions-gh-pages](https://github.com/marketplace/actions/github-pages-action).
## Github pages setting
By default, the GitHub action pushes the generated content to the `gh-pages` branch. This means GitHub has to serve your `gh-pages` branch as a GitHub Pages branch. You can change this setting by going to Settings > GitHub Pages, and change the source branch to `gh-pages`.
## Change baseURL in config.toml
Don't forget to rename your `baseURL` in `config.toml` with the value `https://<USERNAME>.github.io` for your user repository or `https://<USERNAME>.github.io/<REPOSITORY_NAME>` for a project repository.
Unless this is present in your `config.toml`, your website won't work.
## Use a Custom Domain
If you'd like to use a custom domain for your GitHub Pages site, create a file `static/CNAME`. Your custom domain name should be the only contents inside `CNAME`. Since it's inside `static`, the published site will contain the CNAME file at the root of the published site, which is a requirement of GitHub Pages.

View file

@ -6,7 +6,7 @@ date: 2019-06-06
publishdate: 2019-06-06
lastmod: 2020-01-01
categories: [hosting and deployment]
keywords: [render,hosting,deployment]
keywords: [hosting,deployment]
authors: [Anurag Goel]
menu:
docs:

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View file

@ -1,13 +1,12 @@
---
date: 2021-11-02
title: "0.89.0"
description: "0.89.0"
title: "Fine Grained File Filters"
description: "Hugo 0.89.0 brings fine grained file filters, archetype rewrite, dependency refresh, and more ..."
categories: ["Releases"]
---
This release is a dependency refresh (the new Goldmark verion comes with a lot of bug fixes, as one example), many bug fixes, but also some nice new features:
This release is a dependency refresh (the new Goldmark version comes with a lot of bug fixes, as one example), many bug fixes, but also some nice new features:
We have added the [configuration settings](https://gohugo.io/hugo-modules/configuration/#module-config-mounts) **includeFiles** and **excludeFiles** to the mount configuration. This allows fine grained control over what files to include, and it works for all of Hugo's file systems (including `/static`).
@ -17,7 +16,7 @@ We have also [reimplemented archetypes](https://github.com/gohugoio/hugo/pull/90
hugo new content/en/posts/my-first-post.md
```
This release represents **50 contributions by 13 contributors** to the main Hugo code base.[@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@dependabot[bot]](https://github.com/apps/dependabot), [@jmooring](https://github.com/jmooring), and [@anthonyfok](https://github.com/anthonyfok) for their ongoing contributions.
This release represents **50 contributions by 13 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@dependabot[bot]](https://github.com/apps/dependabot), [@jmooring](https://github.com/jmooring), and [@anthonyfok](https://github.com/anthonyfok) for their ongoing contributions.
And thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his ongoing work on keeping the themes site in pristine condition.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
@ -35,10 +34,10 @@ Hugo now has:
* Hugo now writes an empty file named `.hugo_build.lock` to the root of the project when building (also when doing `hugo new mypost.md` and other commands that requires a build). We recommend you just leave this file alone. Put it in `.gitignore` or similar if you don't want the file in your source repository.
* We have updated to ESBuild `v0.13.12`. The release notes for [v0.13.0](https://github.com/evanw/esbuild/releases/tag/v0.13.0) mentions a potential breaking change.
* We now only build AMD64 release binaries (see [this issue](https://github.com/gohugoio/hugo/issues/9102)) for the Unix OSes (e.g. NetBSD). If need, say, a binary for ARM64, you need to build it yourself.
* We now build only one release binary/archive for MacOS, see [this issue](https://github.com/gohugoio/hugo/issues/9035) that works on both Intel and the new Arm M1 systems.
* We now only build AMD64 release binaries (see [this issue](https://github.com/gohugoio/hugo/issues/9102)) for the Unix OSes (e.g. NetBSD). If you need, say, a binary for ARM64, you need to build it yourself.
* We now build only one release binary/archive for MacOS (see [this issue](https://github.com/gohugoio/hugo/issues/9035)) that works on both Intel and the new Arm M1 systems.
* `.File.ContentBaseName` now returns the owning directory name for all bundles (branch an leaf). This is a bug fix, but worth mentioning. See [this issue](https://github.com/gohugoio/hugo/issues/9112).
* We have updated the Twitter shortcode to use Twitter's new API. See [thiss issue] for details.
* We have updated the Twitter shortcode to use Twitter's new API. See [this issue](https://github.com/gohugoio/hugo/pull/9106) for details.
## Enhancements
@ -105,8 +104,3 @@ Hugo now has:
* Fix the "page picker" logic in --navigateToChanged [096f5e19](https://github.com/gohugoio/hugo/commit/096f5e19217e985bccbf6c539e1b220541ffa6f6) [@bep](https://github.com/bep) [#9051](https://github.com/gohugoio/hugo/issues/9051)
* Fix a typo on OpenBSD [c7957c90](https://github.com/gohugoio/hugo/commit/c7957c90e83ff2b2cc958bd61486a244f0fd8891) [@nabbisen](https://github.com/nabbisen)
* Fix value of useResourceCacheWhen in TestResourceChainPostCSS [e6e44b7c](https://github.com/gohugoio/hugo/commit/e6e44b7c41a9b517ffc3775ea0a6aec2b1d4591b) [@jmooring](https://github.com/jmooring)

View file

@ -1,8 +1,8 @@
---
date: 2021-11-17
title: "Hugo 0.89.4: A couple of Bug Fixes"
description: "This version fixes a couple of bugs introduced in 0.89.0."
title: "Hugo 0.89.4: One Bug Fix"
description: "This version fixes one bug introduced in 0.89.0."
categories: ["Releases"]
images:
- images/blog/hugo-bug-poster.png
@ -11,7 +11,7 @@ images:
This is a bug-fix release with one important fix.
This is a bug-fix release with one important fix for people using `hugo new` to create new content:
* Fix content dir resolution when main project is a Hugo Module [2e70f61f](https://github.com/gohugoio/hugo/commit/2e70f61fb04cea08ef6598728a57637ae2cc199c) [@bep](https://github.com/bep) [#9177](https://github.com/gohugoio/hugo/issues/9177)

View file

@ -1,9 +0,0 @@
[**Aether**](https://getaether.net) is an open-source peer-to-peer network that hosts self-moderating online-communities.
[**Aether Pro**](https://aether.app), based on Aether, is a collaboration tool for remote-friendly companies.
The site is built by:
* [Burak Nehbit](https://twitter.com/nehbit)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

View file

@ -1,39 +0,0 @@
---
title: Aether
date: 2020-02-26
description: "Showcase: \"Hugo is not just a static site generator for us, it's the core framework at the heart of our entire web front-end.\""
# The URL to the site on the internet.
siteURL: https://getaether.net
# Add credit to the article author. Leave blank or remove if not needed/wanted.
byline: "[Burak Nehbit](https://twitter.com/nehbit), Maintainer, Aether"
---
To say that this website, our main online presence, needed to do a lot would be an understatement.
Our site is home to both *Aether* and *Aether Pro*, our **knowledgebase for each product**, a **server for static assets that we use in our emails**, the **interactive sign-up flows**, **payments client**, **downloads provider**, and even a **mechanism for delivering auto-update notifications** to our native clients. We are using a single Hugo site for all these — it's not a static site generator for us, it's the core framework at the heart of our *entire* web front-end.
Not only that, this had to work with one developer crunched for time who spends most of his time working on two separate apps across 3 desktop platforms — someone whose main job is very far from building static websites. We only had scraps of time to design and build this Hugo site, make it performant and scalable, and Hugo did a phenomenal job delivering on that promise.
The last piece is, funnily enough, moving our blog to Hugo, which it is not as of now. This was an inherited mistake we are currently rectifying. Soon, our entire web footprint will be living in Hugo.
### Structure
Our website is built in such a way that there is a separate Vue.js instance for each of the contexts since we are not using JS-based single-page navigation. We use Hugo for navigation and to build most pages. For the pages we need to make interactive, we use Vue.js to build individual, self-contained single-page Javascript apps. One such example is our sign-up flow at [aether.app](https://aether.app), an individual Vue app living within a Hugo page, with its own JS-based navigation.
This is a relatively complex setup, and somewhat out of the ordinary. Yet, even with this custom setup, using Hugo was painless.
### Tools
**CMS**: Hugo
**Theme**: Custom-designed
**Hosting**: Netlify, pushed to production via `git push`.
**Javascript runtime**: Vue.js

View file

@ -1,6 +0,0 @@
[Camping Arolla](https://www.camping-arolla.com) is located in the heart of the Swiss Alps, at an altitude of 1.950 meters.
The site is built by:
* [Didier Divinerites](https://github.com/divinerites)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 KiB

View file

@ -1,29 +0,0 @@
---
title: Cocoon & Cosy
date: 2018-08-10
description: "Showcase: \"Emergency setup a dedicated site in an afternoon.\""
siteURL: https://www.cocoon-arolla.com
byline: "[Didier Divinerites](https://github.com/divinerites)"
---
Swiss [Arolla campsite](https://www.camping-arolla.com) runs the highest campsite in Europe and I'm completely re-doing their actual Website with Hugo.
But they just launch a brand new offer (luxury tents with bed and fire oven), and we couldn't wait for the proper new website for having this promoted: we needed the website up and running within 24h!
So we decided to quickly launch a dedicated [independent web site](https://www.cocoon-arolla.com) using all the powerful tools included with [gohugo.io](https://gohugo.io) and some things we already knew & used:
- Choose a spectacular landing theme in the rich [Hugo Themes](https://themes.gohugo.io/) collection : [Airspace Theme](https://themes.gohugo.io/airspace-hugo/) by Themefisher.
- Replace the main images.
- Add a [hugo-easy-gallery / photoswipe](https://github.com/liwenyip/hugo-easy-gallery) on the main page with attractive images.
- Add the promo video with a simple *vimeo* shortcode.
- Replace the Google Maps widget by the [OpenStreetMap](https://www.openstreetmap.org/) equivalent
- Use a [Zotabox](https://www.zotabox.com) contact form.
- Write the content in French & in English directly on the content pages, describe their services, add fun facts and true testimonies.
- Setup a GDPR compliant site with the new Hugo options.
- Use [Netlify](https://www.netlify.com) for publishing it in a breeze.
The first version was up in 4 hours, and the polished 2 languages version was published on Netlify the next day.
This would have been impossible to do it in such a short time without all the powerful Hugo tools and Netlify simplicity.

View file

@ -1,4 +0,0 @@
Pace was started in 2016 to give hotels the super-power to always have the right price.
We've been using **Hugo+Gulp** from the very beginning and the workflow is proving to scale incredibly well with us as we grow the team and business.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

View file

@ -1,28 +0,0 @@
---
title: Pace Revenue Management
date: 2018-02-08
description: "Showcase: \"When we came across Hugo we were blown away.\""
siteURL: https://www.paceup.com/
# Link to the site's Hugo source code if public and you can/want to share.
# Remove or leave blank if not needed/wanted.
# Add credit to the article author. Leave blank or remove if not needed/wanted.
---
From the beginning, at Pace, we were focused on solving customer needs and didn't want to over-engineer our marketing or sales. At the same time we didn't want to lock ourselves into a WordPress, Squarespace or the like.
The ideal was a fast, simple, static site builder. When we came across Hugo we were blown away. Being a European company we wanted to be multi-lingual from the get-go and allow multiple team-members to collaborate and own their content. We also felt that a tech-company in 2018 should be capable of hosting its own blog in a simple way.
Here was Hugo, that allowed us to completely separate content from layout. Our sales-team edit a markdown-file, the engineers commit and off we go -- immediately deployable or pre-viewable.
The only other way to have all that Hugo offers is to go down the full rabbit-hole of building your own server-side React or some such. Possibly Jekyll but again very complex to work with. The alternatives come with too much work for what should be quite simple.
**Hugo + Gulp + Netlify for the win! Don't over engineer your web presence!**
Huge thanks to [@bep](https://github.com/bep) and [community](https://discourse.gohugo.io/) for Hugo.

View file

@ -69,7 +69,7 @@ Hugo also ships with an internal template for [Disqus comments][disqus], a popul
To use Hugo's Disqus template, you first need to set a single configuration value:
{{< code-toggle file="config" >}}
disqusShortname = "yourdiscussshortname"
disqusShortname = "your-disqus-shortname"
{{</ code-toggle >}}
You also have the option to set the following in the front matter for a given piece of content:
@ -209,7 +209,6 @@ To add Twitter card metadata, include the following line between the `<head>` ta
## The Internal Templates
* `_internal/disqus.html`
* `_internal/google_news.html`
* `_internal/google_analytics.html`
* `_internal/google_analytics_async.html`
* `_internal/opengraph.html`

View file

@ -151,7 +151,7 @@ Go Templates only ship with a few basic functions but also provide a mechanism f
<!-- prints true (i.e., since 1 is less than 2) -->
```
Note that both examples make use of Go Template's [math functions][].
Note that both examples make use of Go Template's [math]][] functions.
{{% note "Additional Boolean Operators" %}}
There are more boolean operators than those listed in the Hugo docs in the [Go Template documentation](https://golang.org/pkg/text/template/#hdr-Functions).
@ -184,7 +184,7 @@ Example of including a `layouts/partials/header.html` partial:
The `template` function was used to include *partial* templates
in much older Hugo versions. Now it's useful only for calling
[*internal* templates][internal_templates]. The syntax is `{{ template
[*internal* templates][internal templates]. The syntax is `{{ template
"_internal/<TEMPLATE>.<EXTENSION>" . }}`.
{{% note %}}
@ -630,48 +630,69 @@ Finally, you can pull "magic constants" out of your layouts as well. The followi
</nav>
```
## Example: Show Only Upcoming Events
## Example: Show Future Events
Go allows you to do more than what's shown here. Using Hugo's [`where` function][where] and Go built-ins, we can list only the items from `content/events/` whose date (set in a content file's [front matter][]) is in the future. The following is an example [partial template][partials]:
Given the following content structure and [front matter]:
{{< code file="layouts/partials/upcoming-events.html" download="upcoming-events.html" >}}
<h4>Upcoming Events</h4>
<ul class="upcoming-events">
{{ range where .Pages.ByDate "Section" "events" }}
{{ if ge .Date.Unix now.Unix }}
```text
content/
└── events/
├── event-1.md
├── event-2.md
└── event-3.md
```
{{< code-toggle file="content/events/event-1.md" copy="false" >}}
title = 'Event 1'
date = 2021-12-06T10:37:16-08:00
draft = false
start_date = 2021-12-05T09:00:00-08:00
end_date = 2021-12-05T11:00:00-08:00
{{< /code-toggle >}}
This [partial template][partials] renders future events:
{{< code file="layouts/partials/future-events.html" >}}
<h2>Future Events</h2>
<ul>
{{ range where site.RegularPages "Type" "events" }}
{{ if gt (.Params.start_date | time.AsTime) now }}
{{ $startDate := .Params.start_date | time.Format ":date_medium" }}
<li>
<!-- add span for event type -->
<span>{{ .Type | title }} —</span>
{{ .Title }} on
<!-- add span for event date -->
<span>{{ .Date.Format "2 January at 3:04pm" }}</span>
at {{ .Params.place }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> - {{ $startDate }}
</li>
{{ end }}
{{ end }}
{{ end }}
</ul>
{{< /code >}}
If you restrict front matter to the TOML format, and omit quotation marks surrounding date fields, you can perform date comparisons without casting.
[`where` function]: /functions/where/
[config]: /getting-started/configuration/
{{< code file="layouts/partials/future-events.html" >}}
<h2>Future Events</h2>
<ul>
{{ range where (where site.RegularPages "Type" "events") "Params.start_date" "gt" now }}
{{ $startDate := .Params.start_date | time.Format ":date_medium" }}
<li>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> - {{ $startDate }}
</li>
{{ end }}
</ul>
{{< /code >}}
[config]: {{< relref "getting-started/configuration" >}}
[dotdoc]: https://golang.org/pkg/text/template/#hdr-Variables
[first]: /functions/first/
[front matter]: /content-management/front-matter/
[functions]: /functions/ "See the full list of Hugo's templating functions with a quick start reference guide and basic and advanced examples."
[Go html/template]: https://golang.org/pkg/html/template/ "Godocs references for Go's html templating"
[gohtmltemplate]: https://golang.org/pkg/html/template/ "Godocs references for Go's html templating"
[index]: /functions/index-function/
[math functions]: /functions/math/
[partials]: /templates/partials/ "Link to the partial templates page inside of the templating section of the Hugo docs"
[internal_templates]: /templates/internal/
[relpermalink]: /variables/page/
[safehtml]: /functions/safehtml/
[sitevars]: /variables/site/
[pagevars]: /variables/page/
[variables]: /variables/ "See the full extent of page-, site-, and other variables that Hugo make available to you in your templates."
[where]: /functions/where/
[with]: /functions/with/
[godocsindex]: https://golang.org/pkg/text/template/ "Godocs page for index function"
[param]: /functions/param/
[isset]: /functions/isset/
[first]: {{< relref "functions/first" >}}
[front matter]: {{< relref "content-management/front-matter" >}}
[functions]: {{< relref "functions" >}}
[internal templates]: {{< relref "templates/internal" >}}
[isset]: {{< relref "functions/isset" >}}
[math]: {{< relref "functions/math" >}}
[pagevars]: {{< relref "variables/page" >}}
[param]: {{< relref "functions/param" >}}
[partials]: {{< relref "templates/partials" >}}
[relpermalink]: {{< relref "variables/page#page-variables" >}}
[safehtml]: {{< relref "functions/safehtml" >}}
[sitevars]: {{< relref "variables/site" >}}
[variables]: {{< relref "variables" >}}
[with]: {{< relref "functions/with" >}}

View file

@ -72,7 +72,7 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo
: indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition.
.Site.LanguageCode
: a string representing the language as defined in the site configuration. This is mostly used to populate the RSS feeds with the right language code.
: a string representing the language tag as defined in the site configuration.
.Site.LanguagePrefix
: this can be used to prefix URLs to point to the correct language. It will even work when only one defined language. See also the functions [absLangURL](/functions/abslangurl/) and [relLangURL](/functions/rellangurl).

View file

@ -29,7 +29,7 @@
<div class="tab-content">
{{ range $langs }}
<div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" ""}}">
{{ highlight ($code | transform.Remarshal . | safeHTML) . ""}}
{{ highlight ($code | transform.Remarshal . | replaceRE `\n+` "\n" | safeHTML) . "" }}
</div>
{{ if ne ($.Get "copy") "false" }}
<button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>

View file

@ -4,8 +4,9 @@
{{ range $k, $v := $funcs }}
{{ if $v.Description }}
{{ $func := printf "%s.%s" $pkg $k }}
<h2>
<a class="header-link" href="#{{ $func | anchorize | safeURL }}">
{{ $id := $func | anchorize | safeURL }}
<h2 id="{{ $id }}">
<a class="header-link" href="#{{ $id }}">
<svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>

View file

@ -3,7 +3,7 @@ publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.88.1"
HUGO_VERSION = "0.89.4"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_VERSION = "0.88.1"
HUGO_VERSION = "0.89.4"
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment]
HUGO_VERSION = "0.88.1"
HUGO_VERSION = "0.89.4"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment]
HUGO_VERSION = "0.88.1"
HUGO_VERSION = "0.89.4"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"