Squashed 'docs/' changes from 501c6e233..f59b3ab06

f59b3ab06 Fix typo in template lookup order
1e5536d6c Mutlilingual: Document "content directory per language" system (#509)
849a86048 Update index.md
0c24d229b Polish Hugo Next
a4c9b0ee2 Polish
bbec2c76e Some more in birthday post
fc9681e21 More on contributors
09fe3ea31 Some more on the birthday post
8da357240 Content and images for the 5th birthday blog post
fb45bb8dc Add draft for anniversary blog post
4666d0a18 Release 0.42.2
9b74d286a Merge branch 'temp422'
354e7b66b releaser: Add release notes to /docs for release of 0.42.2
57a617f34 releaser: Bump versions for release of 0.42.2
ccc3ac1b8 Update errorf.md
35706c21a Update errorf.md
1c0f35fd1 Update errorf.md
b6170774b Add syntax highlighting gallery links for Chroma
f91d9da47 Update usage.md
c9a8f0190 Improve theme components documentation
3c4e39ddd Release 0.42.1
b45eb453f Merge branch 'temp421'
c74682a10 releaser: Prepare repository for 0.43-DEV
321e07fa5 releaser: Add release notes to /docs for release of 0.42.1
7154271e0 releaser: Bump versions for release of 0.42.1
360d8244f Add link to Privacy Config
1f2454247 Fix typo
a8f5f994e Fix typo
d9f3f078c Update simple variants documentation (#500)
f5cfd44e0 Release 0.42
fe604b321 releaser: Prepare repository for 0.43-DEV
c3e5b3ca0 releaser: Add release notes to /docs for release of 0.42
3174d1b37 releaser: Bump versions for release of 0.42
48cc2d51f docs: Update theme documentation
1922fb1a6 docs: Remove some files now moved
d7e4c453a Merge commit 'b239595af5a9fc1fc9a1ccc666c3ab06ccc32f04'
c40964c1b tplimpl: Remove speakerdeck shortcode
081f8a0f9 tpl/strings: strings.RuneCount
828ea5f15 tpl: Add strings.Repeat
a6b9f654a Add a BlackFriday option for rel="noreferrer" on external links
edb786516 Add a BlackFriday option for rel="nofollow" on external links
e4374971f releaser: Prepare repository for 0.42-DEV

git-subtree-dir: docs
git-subtree-split: f59b3ab06f282c26bce07263c8be6672cf8f7969
This commit is contained in:
Bjørn Erik Pedersen 2018-07-06 17:52:13 +02:00
parent b239595af5
commit 98293eaa15
34 changed files with 578 additions and 251 deletions

View file

@ -70,7 +70,7 @@ twitter = "GoHugoIO"
[params] [params]
description = "The worlds fastest framework for building websites" description = "The worlds fastest framework for building websites"
## Used for views in rendered HTML (i.e., rather than using the .Hugo variable) ## Used for views in rendered HTML (i.e., rather than using the .Hugo variable)
release = "0.41" release = "0.42.2"
## Setting this to true will add a "noindex" to *EVERY* page on the site ## Setting this to true will add a "noindex" to *EVERY* page on the site
removefromexternalsearch = false removefromexternalsearch = false
## Gh repo for site footer (include trailing slash) ## Gh repo for site footer (include trailing slash)

View file

@ -46,13 +46,13 @@ useSessionStorage = false
[privacy.instagram] [privacy.instagram]
disable = false disable = false
simple = false simple = false
[privacy.speakerDeck]
disable = false
[privacy.twitter] [privacy.twitter]
disable = false disable = false
enableDNT = false enableDNT = false
simple = false
[privacy.vimeo] [privacy.vimeo]
disable = false disable = false
simple = false
[privacy.youtube] [privacy.youtube]
disable = false disable = false
privacyEnhanced = false privacyEnhanced = false
@ -71,8 +71,6 @@ disable = true
disable = true disable = true
[privacy.instagram] [privacy.instagram]
disable = true disable = true
[privacy.speakerDeck]
disable = true
[privacy.twitter] [privacy.twitter]
disable = true disable = true
[privacy.vimeo] [privacy.vimeo]
@ -112,8 +110,25 @@ disableInlineCSS = true
enableDNT enableDNT
: Enabling this for the twitter/tweet shortcode, the tweet and its embedded page on your site are not used for purposes that include personalized suggestions and personalized ads. : Enabling this for the twitter/tweet shortcode, the tweet and its embedded page on your site are not used for purposes that include personalized suggestions and personalized ads.
simple
: If simple mode is enabled, a static and no-JS version of a tweet will be built.
**Note:** If you use the _simple mode_ for Twitter, you may want to disable the inlines styles provided by Hugo:
{{< code-toggle file="config">}}
[services]
[services.twitter]
disableInlineCSS = true
{{< /code-toggle >}}
### YouTube ### YouTube
privacyEnhanced privacyEnhanced
: When you turn on privacy-enhanced mode, YouTube wont store information about visitors on your website unless the user plays the embedded video. : When you turn on privacy-enhanced mode, YouTube wont store information about visitors on your website unless the user plays the embedded video.
### Vimeo
simple
: If simple mode is enabled, the video thumbnail is fetched from Vimeo's servers and it is overlayed with a play button. If the user clicks to play the video, it will open in a new tab directly on Vimeo's website.

View file

@ -35,14 +35,13 @@ help = "Help"
title = "My blog" title = "My blog"
weight = 1 weight = 1
[languages.en.params] [languages.en.params]
linkedin = "english-link" linkedin = "https://linkedin.com/whoever"
[languages.fr] [languages.fr]
copyright = "Tout est à moi" title = "Mon blogue"
title = "Mon blog"
weight = 2 weight = 2
[languages.fr.params] [languages.fr.params]
linkedin = "lien-francais" linkedin = "https://linkedin.com/fr/whoever"
[languages.fr.params.navigation] [languages.fr.params.navigation]
help = "Aide" help = "Aide"
{{< /code-toggle >}} {{< /code-toggle >}}
@ -55,11 +54,13 @@ and taxonomy pages will be rendered below `/` in English (your default content l
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][singles], omit the `params` in the key for the translation.
If you want all of the languages to be put below their respective language code, enable `defaultContentLanguageInSubdir: true`. `defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`.
If the default language needs to be rendererd below its own language code (`/en`) like the others, set `defaultContentLanguageInSubdir: true`.
Only the obvious non-global options can be overridden per language. Examples of global options are `baseURL`, `buildDrafts`, etc. Only the obvious non-global options can be overridden per language. Examples of global options are `baseURL`, `buildDrafts`, etc.
## Disable a Language ### Disable a Language
You can disable one or more languages. This can be useful when working on a new translation. You can disable one or more languages. This can be useful when working on a new translation.
@ -81,7 +82,7 @@ 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. From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details.
@ -94,11 +95,11 @@ Example:
{{< code-toggle file="config" >}} {{< code-toggle file="config" >}}
[languages] [languages]
[languages.no] [languages.fr]
baseURL = "https://example.no" baseURL = "https://example.fr"
languageName = "Norsk" languageName = "Français"
weight = 1 weight = 1
title = "På norsk" title = "En Français"
[languages.en] [languages.en]
baseURL = "https://example.com" baseURL = "https://example.com"
@ -127,7 +128,7 @@ Press Ctrl+C to stop
Live reload and `--navigateToChanged` between the servers work as expected. Live reload and `--navigateToChanged` between the servers work as expected.
## Taxonomies and Blackfriday ### Taxonomies and Blackfriday
Taxonomies and [Blackfriday configuration][config] can also be set per language: Taxonomies and [Blackfriday configuration][config] can also be set per language:
@ -156,40 +157,113 @@ plaque = "plaques"
## Translate Your Content ## Translate Your Content
Translated articles are identified by the name of the content file. There are two ways to manage your content translation, both ensures each page is assigned a language and linked to its translations.
### Examples of Translated Articles ### Translation by filename
Considering the following example:
1. `/content/about.en.md` 1. `/content/about.en.md`
2. `/content/about.fr.md` 2. `/content/about.fr.md`
In this example, the `about.md` will be assigned the configured `defaultContentLanguage`. The first file is assigned the english language and linked to the second.
The second file is assigned the french language and linked to the first.
1. `/content/about.md` Their language is __assigned__ according to the language code added as __suffix to the filename__.
2. `/content/about.fr.md`
This way, you can slowly start to translate your current content without having to rename everything. If left unspecified, the default value for `defaultContentLanguage` is `en`. By having the same **path and base filename**, the content pieces are __linked__ together as translated pages.
{{< note >}}
By having the same **directory and base filename**, the content pieces are linked together as translated pieces. If a file is missing any language code, it will be assigned the default language.
You can also set the key used to link the translations explicitly in front matter: {{</ note >}}
### 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.
{{< code-toggle file="config" >}}
languages:
en:
weight: 10
languageName: "English"
contentDir: "content/english"
nn:
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.
Considering the following example in conjunction with the configuration above:
1. `/content/english/about.md`
2. `/content/french/about.md`
The first file is assigned the english language and is linked to the second.
<br>The second file is assigned the french language and is linked to the first.
Their language is __assigned__ according to the content directory they are __placed__ in.
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.
Any pages sharing the same `translationKey` set in front matter will be linked as translated pages regardless of basename or location.
Considering the following example:
1. `/content/about-us.en.md`
2. `/content/om.nn.md`
3. `/content/presentation/a-propos.fr.md`
```yaml ```yaml
translationKey: "my-story" # set in all three pages
translationKey: "about"
``` ```
If you need distinct URLs per language, you can set the slug in the non-default language file. For example, you can define a custom slug for a French translation in the front matter of `content/about.fr.md` as follows: By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages.
```yaml
### Localizing permalinks
Because paths and filenames are used to handle linking, all translated pages, except for the language part, will be sharing the same url.
To localize the URLs, the [`slug`]({{< ref "content-management/organization/index.md#slug" >}}) or [`url`]({{< ref "content-management/organization/index.md#url" >}}) front matter param can be set in any of the non-default language file.
For example, a french translation (`content/about.fr.md`) can have its own localized slug.
{{< code-toggle >}}
Title: A Propos
slug: "a-propos" slug: "a-propos"
{{< /code-toggle >}}
```
At render, Hugo will build both `/about/` and `/a-propos/` as properly linked translated pages. At render, Hugo will build both `/about/` and `fr/a-propos/` while maintaning their translation linking.
{{% note %}}
If using `url`, remember to include the language part as well: `fr/compagnie/a-propos/`.
{{%/ note %}}
For merging of content from other languages (i.e. missing content translations), see [lang.Merge](/functions/lang.merge/). ### Page Bundles
## Link to Translated Content 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...).
Therefore, from within a template, the page will have access to the files from all linked pages' bundles.
If, across the linked bundles, two or more files share the same basenname, only one will be included and chosen as follows:
* File from current language Bundle, if present.
* First file found across bundles by order of language `Weight`.
{{% note %}}
Page Bundle's resources follow the same language assignement logic as content files, be it by filename (`image.jpg`, `image.fr.jpg`) or by directory (`english/about/header.jpg`, `french/about/header.jpg`).
{{%/ note %}}
## Reference the Translated Content
To create a list of links to translated content, use a template similar to the following: To create a list of links to translated content, use a template similar to the following:
@ -210,7 +284,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. 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 itself. Called on the home page it can be used to build a language navigator: `.AllTranslations` on a `Page` can be used to list all translations, including itself. Called on the home page it can be used to build a language navigator:
@ -366,7 +440,7 @@ For merging of content from other languages (i.e. missing content translations),
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: 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:
* Come from the built-in `.Permalink` or `.URL` * Come from the built-in `.Permalink` or `.RelPermalink`
* Be constructed with * Be constructed with
* The [`relLangURL` template function][rellangurl] or the [`absLangURL` template function][abslangurl] **OR** * The [`relLangURL` template function][rellangurl] or the [`absLangURL` template function][abslangurl] **OR**
* Prefixed with `{{ .LanguagePrefix }}` * Prefixed with `{{ .LanguagePrefix }}`

View file

@ -374,6 +374,10 @@ Using the preceding `youtube` example (without `autoplay="true"`), the following
{{< youtube w7Ft2ymGmfc >}} {{< youtube w7Ft2ymGmfc >}}
## Privacy Config
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][]. To learn more about creating custom shortcodes, see the [shortcode template documentation][].
@ -382,6 +386,7 @@ To learn more about creating custom shortcodes, see the [shortcode template docu
[contentmanagementsection]: /content-management/formats/ [contentmanagementsection]: /content-management/formats/
[examplegist]: https://gist.github.com/spf13/7896402 [examplegist]: https://gist.github.com/spf13/7896402
[figureelement]: http://html5doctor.com/the-figure-figcaption-elements/ "An article from HTML5 doctor discussing the fig and figcaption elements." [figureelement]: http://html5doctor.com/the-figure-figcaption-elements/ "An article from HTML5 doctor discussing the fig and figcaption elements."
[Hugo and the GDPR]: /about/hugo-and-gdpr/
[Instagram]: https://www.instagram.com/ [Instagram]: https://www.instagram.com/
[pagevariables]: /variables/page/ [pagevariables]: /variables/page/
[partials]: /templates/partials/ [partials]: /templates/partials/
@ -390,7 +395,6 @@ To learn more about creating custom shortcodes, see the [shortcode template docu
[sctemps]: /templates/shortcode-templates/ [sctemps]: /templates/shortcode-templates/
[scvars]: /variables/shortcodes/ [scvars]: /variables/shortcodes/
[shortcode template documentation]: /templates/shortcode-templates/ [shortcode template documentation]: /templates/shortcode-templates/
[Speaker Deck]: https://speakerdeck.com/
[templatessection]: /templates/ [templatessection]: /templates/
[Vimeo]: https://vimeo.com/ [Vimeo]: https://vimeo.com/
[YouTube Videos]: https://www.youtube.com/ [YouTube Videos]: https://www.youtube.com/

View file

@ -72,7 +72,13 @@ pygmentsCodefences
: Set to true to enable syntax highlighting in code fences with a language tag in markdown (see below for an example). : Set to true to enable syntax highlighting in code fences with a language tag in markdown (see below for an example).
pygmentsStyle pygmentsStyle
: The style of code highlighting. See https://help.farbox.com/pygments.html for a gallery. Note that this option is not relevant when `pygmentsUseClasses` is set. : The style of code highlighting. Note that this option is not
relevant when `pygmentsUseClasses` is set.
Syntax highlighting galleries:
**Chroma** ([short snippets](https://xyproto.github.io/splash/docs/all.html),
[long snippets](https://xyproto.github.io/splash/docs/longer/all.html)),
[Pygments](https://help.farbox.com/pygments.html)
pygmentsUseClasses pygmentsUseClasses
: Set to `true` to use CSS classes to format your highlighted code. See [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css). : Set to `true` to use CSS classes to format your highlighted code. See [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css).

View file

@ -1,7 +1,7 @@
--- ---
title: errorf title: errorf
linktitle: errorf linktitle: errorf
description: Evaluates a format string and logs it to ERROR. description: Log ERROR and fail the build from the templates.
date: 2017-09-30 date: 2017-09-30
publishdate: 2017-09-30 publishdate: 2017-09-30
lastmod: 2017-09-30 lastmod: 2017-09-30
@ -18,9 +18,12 @@ deprecated: false
aliases: [] aliases: []
--- ---
`errorf` will evaluate a format string, then output the result to the ERROR log. `errorf` will evaluate a format string, then output the result to the ERROR log (and only once per error message to avoid flooding the log).
This will also cause the build to fail.
This will also cause the build to fail (the `hugo` command will `exit -1`).
``` ```
{{ errorf "Something went horribly wrong! %s" err }} {{ errorf "Failed to handle page %q" .Path }}
``` ```
Note that `errorf` supports all the formatting verbs of the [fmt](https://golang.org/pkg/fmt/) package.

View file

@ -0,0 +1,31 @@
---
title: strings.Repeat
# linktitle:
description: Returns a string consisting of count copies of the string s.
godocref:
date: 2018-05-31
publishdate: 2018-05-31
lastmod: 2018-05-31
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [strings]
signature: ["strings.Repeat INPUT COUNT"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
---
`strings.Repeat` provides the Go [`strings.Repeat`](https://golang.org/pkg/strings/#Repeat) function for Hugo templates. It takes a string and a count, and returns a string with consisting of count copies of the string argument.
```
{{ strings.Repeat "yo" 3 }} → "yoyoyo"
```
`strings.Repeat` *requires* the second argument, which tells the function how many times to repeat the first argument; there is no default. However, it can be used as a pipeline:
```
{{ "yo" | strings.Repeat 3 }} → "yoyoyo"
```

View file

@ -0,0 +1,28 @@
---
title: strings.RuneCount
description: Determines the number of runes in a string.
godocref:
date: 2018-06-01
publishdate: 2018-06-01
lastmod: 2018-06-01
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [counting, character count, length, rune length, rune count]
signature: ["strings.RuneCount INPUT"]
workson: []
hugoversion:
relatedfuncs: ["len", "countrunes"]
deprecated: false
aliases: []
---
In contrast with `strings.CountRunes` function, which strips HTML and whitespace before counting runes, `strings.RuneCount` simply counts all the runes in a string. It relies on the Go [`utf8.RuneCountInString`] function.
```
{{ "Hello, 世界" | strings.RuneCount }}
<!-- outputs a content length of 9 runes. -->
```
[`utf8.RuneCount`]: https://golang.org/pkg/unicode/utf8/#RuneCount

View file

@ -104,7 +104,7 @@ The most common usage is probably to run `hugo` with your current directory bein
This generates your website to the `public/` directory by default, although you can customize the output directory in your [site configuration][config] by changing the `publishDir` field. This generates your website to the `public/` directory by default, although you can customize the output directory in your [site configuration][config] by changing the `publishDir` field.
The site Hugo renders into `public/` is ready to be deployed to your web server: The command `hugo` renders your site into `public/` dir and is ready to be deployed to your web server:
``` ```
hugo hugo

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View file

@ -0,0 +1,66 @@
---
date: 2018-06-12
title: "Hugo 0.42: Theme Composition and Inheritance!"
description: "Hugo 0.42 adds Theme Components support, a new and powerful way of composing your Hugo sites."
categories: ["Releases"]
---
Hugo `0.42` adds **Theme Components**. This is a really powerful new way of building your Hugo sites with reusable components. This is both **Theme Composition** and **Theme Inheritance**.
>Read more about Theme Components in the [Hugo Documentation](https://gohugo.io/themes/theme-components/).
The feature above was implemented by [@bep](https://github.com/bep), the funny Norwegian, with great design help from the Hugo community. But that implementation would not have been possible without [Afero](https://github.com/spf13/afero), [Steve Francia's](https://github.com/spf13) virtual file system. Hugo is built on top of Afero and many other fast and solid Go projects, and if you look at the combined contribution log of the Hugo project and its many open source dependencies, the total amount of contributions is staggering. A big thank you to them all!
This release represents **27 contributions by 7 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 [@onedrawingperday](https://github.com/onedrawingperday), [@anthonyfok](https://github.com/anthonyfok), and [@stefanneuhaus](https://github.com/stefanneuhaus) for their ongoing contributions.
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the themes site in pristine condition and to [@kaushalmodi](https://github.com/kaushalmodi) for his great work on the documentation site.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
which has received **8 contributions by 5 contributors**. A special thanks to [@bep](https://github.com/bep), [@LorenzCK](https://github.com/LorenzCK), [@gavinwray](https://github.com/gavinwray), and [@deyton](https://github.com/deyton) for their work on the documentation site.
Hugo now has:
* 26286+ [stars](https://github.com/gohugoio/hugo/stargazers)
* 444+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
* 235+ [themes](http://themes.gohugo.io/)
## Notes
* The `speakerdeck` shortcode is removed. It didn't work properly, so is isn't expected to be in wide use. If you use it, you will get a build error. You will either have to remove its usage or add a `speakerdeck` shortcode to your own project or theme.
* We have now virtualized the filesystems for project and theme files. This makes everything simpler, faster and more powerful. But it also means that template lookups on the form `{{ template “theme/partials/pagination.html” . }}` will not work anymore. That syntax has never been documented, so it's not expected to be in wide use. `{{ partial "pagination.html" . }}` will give you the most specific version of that partial.
## Enhancements
* Always load GA script over HTTPS [2e6712e2](https://github.com/gohugoio/hugo/commit/2e6712e2814f333caa807888c1d8a9a5a3c03709) [@coliff](https://github.com/coliff)
* Remove speakerdeck shortcode [65deb72d](https://github.com/gohugoio/hugo/commit/65deb72dc4c9299416cf2d9defddb96dba4101fd) [@onedrawingperday](https://github.com/onedrawingperday) [#4830](https://github.com/gohugoio/hugo/issues/4830)
* Add `strings.RuneCount` [019bd557](https://github.com/gohugoio/hugo/commit/019bd5576be87c9f06b6a928ede1a5e78677f7b3) [@theory](https://github.com/theory)
* Add `strings.Repeat` [13435a6f](https://github.com/gohugoio/hugo/commit/13435a6f608306c5094fdcd72a1d9538727f91b2) [@theory](https://github.com/theory)
* Reset Page's main output on server rebuilds [dc4226a8](https://github.com/gohugoio/hugo/commit/dc4226a8b27e03e31068fc945daab885d3819d04) [@bep](https://github.com/bep) [#4819](https://github.com/gohugoio/hugo/issues/4819)
* Create LICENSE rather than LICENSE.md in "new theme" [ed4a345e](https://github.com/gohugoio/hugo/commit/ed4a345efeaa19eef2c1c6360d22f75c24abc31a) [@anthonyfok](https://github.com/anthonyfok) [#4623](https://github.com/gohugoio/hugo/issues/4623)
* Create `_default/baseof.html` in "new theme" [9717ac7d](https://github.com/gohugoio/hugo/commit/9717ac7dce84d004afde4edb32ad81319c7dd8a7) [@anthonyfok](https://github.com/anthonyfok) [#3576](https://github.com/gohugoio/hugo/issues/3576)
* Add `tweet_simple`shortcode [07b96d16](https://github.com/gohugoio/hugo/commit/07b96d16e8679c40e289c9076ef4414ed6eb7f81) [@onedrawingperday](https://github.com/onedrawingperday)
* Make "new theme" feedback more intuitive [692ec008](https://github.com/gohugoio/hugo/commit/692ec008726b570c9b30ac3391774cbb622730cb) [@anthonyfok](https://github.com/anthonyfok)
* Move nextStepsText() to new_site.go [d3dd74fd](https://github.com/gohugoio/hugo/commit/d3dd74fd655c22f21e91e38edb1d377a1357e3be) [@anthonyfok](https://github.com/anthonyfok)
* Add support for theme composition and inheritance [80230f26](https://github.com/gohugoio/hugo/commit/80230f26a3020ff33bac2bef01b2c0e314b89f86) [@bep](https://github.com/bep) [#4460](https://github.com/gohugoio/hugo/issues/4460)[#4450](https://github.com/gohugoio/hugo/issues/4450)
* Add vimeo_simple [8de53244](https://github.com/gohugoio/hugo/commit/8de53244799f0d2d0343056d348d810343cf7aa5) [@onedrawingperday](https://github.com/onedrawingperday) [#4749](https://github.com/gohugoio/hugo/issues/4749)
* Add a BlackFriday option for rel="noreferrer" on external links [20cbc2c7](https://github.com/gohugoio/hugo/commit/20cbc2c7856a9b07d45648d940276374db35e425) [@stefanneuhaus](https://github.com/stefanneuhaus) [#4722](https://github.com/gohugoio/hugo/issues/4722)
* Add a BlackFriday option for rel="nofollow" on external links [7a619264](https://github.com/gohugoio/hugo/commit/7a6192647a4b383cd539df2063388ea380371de6) [@stefanneuhaus](https://github.com/stefanneuhaus) [#4722](https://github.com/gohugoio/hugo/issues/4722)
* Update Chroma [b5b36e32](https://github.com/gohugoio/hugo/commit/b5b36e32008bc8ea779ae06bf249b537f6d5c336) [@bep](https://github.com/bep) [#4779](https://github.com/gohugoio/hugo/issues/4779)
* Enhance Page and Resource String() [4f0665f4](https://github.com/gohugoio/hugo/commit/4f0665f476e06e9707621c18f7422fdeb776e0d1) [@vassudanagunta](https://github.com/vassudanagunta)
* Update theme documentation [c74b0f8f](https://github.com/gohugoio/hugo/commit/c74b0f8f9b30866e09efac8235cc5e0093ab3d50) [@bep](https://github.com/bep) [#4460](https://github.com/gohugoio/hugo/issues/4460)
## Fixes
* Make sure that `.Site.Taxonomies` is always set on rebuilds [6464981a](https://github.com/gohugoio/hugo/commit/6464981adb4d7d0f41e8e2c987342082982210a1) [@bep](https://github.com/bep) [#4838](https://github.com/gohugoio/hugo/issues/4838)
* Reset the "distinct error logger" on rebuilds [bf5f10fa](https://github.com/gohugoio/hugo/commit/bf5f10faa9fd445c4dd21839aa7d73cd2acbfb85) [@bep](https://github.com/bep) [#4818](https://github.com/gohugoio/hugo/issues/4818)
* Remove frameborder attr YT iframe + CSS fixes [ceaff7ca](https://github.com/gohugoio/hugo/commit/ceaff7cafc5357274e546984ae02a4cbdf305f81) [@onedrawingperday](https://github.com/onedrawingperday)
* Fix vimeo_simple thumb scaling [b84389c5](https://github.com/gohugoio/hugo/commit/b84389c5e0e1ef15449b24d488bbbcbc41245c59) [@onedrawingperday](https://github.com/onedrawingperday)
* Fix typo instagram_simple [d68367cb](https://github.com/gohugoio/hugo/commit/d68367cbe76cbc02adb5b778e8be98bed6319368) [@onedrawingperday](https://github.com/onedrawingperday)
* Prevent isBaseTemplate() from matching "baseof" in dir [c3115292](https://github.com/gohugoio/hugo/commit/c3115292a7f2d2623cb45054a361e997ad9330c9) [@anthonyfok](https://github.com/anthonyfok) [#4809](https://github.com/gohugoio/hugo/issues/4809)

View file

@ -0,0 +1,16 @@
---
date: 2018-06-13
title: "Hugo 0.42.1: Two Bug Fixes"
description: "Hugo 0.42.1 fixes two issues."
categories: ["Releases"]
images:
- images/blog/hugo-bug-poster.png
---
This is a bug-fix release with two fixes:
* Reset the global pages cache on server rebuilds [128f14ef](https://github.com/gohugoio/hugo/commit/128f14efad90886ffef37c01ac1e20436a732f97) [@bep](https://github.com/bep) [#4845](https://github.com/gohugoio/hugo/issues/4845)
* Do not fail server build when /static is missing [34ee27a7](https://github.com/gohugoio/hugo/commit/34ee27a78b9e2b5f475d44253ae234067b76cc6e) [@bep](https://github.com/bep) [#4846](https://github.com/gohugoio/hugo/issues/4846)

View file

@ -0,0 +1,18 @@
---
date: 2018-06-28
title: "Hugo 0.42.2: One Bug Fix"
description: "Hugo 0.42.2 fixes server reload on config changes."
categories: ["Releases"]
images:
- images/blog/hugo-bug-poster.png
---
This release fixes broken server-reload on config changes. This is a regression from Hugo `0.42`. [3a7706b0](https://github.com/gohugoio/hugo/commit/3a7706b069107e5fa6112b3f7ce006f16867cb38) [@bep](https://github.com/bep) [#4878](https://github.com/gohugoio/hugo/issues/4878)

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -0,0 +1,108 @@
---
date: 2018-07-04
title: "Lets celebrate Hugos 5th birthday"
description: "How a side project became one of the most popular frameworks for building websites."
categories: [blog]
author: bep
---
_By Bjørn Erik Pedersen ([@bepsays](https://twitter.com/bepsays) / [@bep](https://github.com/bep)), Hugo Lead_
**Five years ago today, [Steve Francia](https://github.com/spf13/) made his [first commit](https://github.com/gohugoio/hugo/commit/50a1d6f3f155ab837310e00ffb309a9199773c73
) on the Hugo project: "Hugo: A Fast and Flexible Static Site Generator built with love by spf13 in GoLang".**
Steve was writing that on a train commute to New York. I'm writing this article running Hugo `v0.43-DEV`, the preview version of the next Hugo release. The release is scheduled for Monday and adds a powerful [assets pipeline](https://github.com/gohugoio/hugo/issues/4854#issue-333062459), with SCSS/SASS support, assets minification, fingerprinting/subresource integrity, ad-hoc image processing and much more.
**I cannot remember the last time I was this excited about a Hugo release. "Game changer" may be too strong, but it makes for a really nice integrated website design-workflow that, with Hugo's build speed, is hard to beat.**
{{< imgproc sunset Fill "600x300" >}}
Fetch and scale an image in the upcoming Hugo 0.43.
{{< /imgproc >}}
But that is a release for Monday. Now is a time to look at the current status of Hugo after the first five years.
## Hugo in Numbers
According to [BuiltWith](https://trends.builtwith.com/cms/Hugo), more than 29 000 live websites are built with Hugo. Of those, 390 are in the top 1 million. Wappalyzer [reports](https://www.wappalyzer.com/categories/static-site-generator) that Hugo serves almost 50% of the static sites.
Hugo is big in the [public sector](https://discourse.gohugo.io/t/hugo-in-public-administration/8792), with the US Government as a prominent user. Some examples are [vote.gov](https://vote.gov/) and [digital.gov](https://digital.gov/).
[Smashing Magazine](https://www.smashingmagazine.com/) is a big and very popular Hugo site. It is [reported](https://discourse.gohugo.io/t/smashing-magazine-s-redesign-powered-by-hugo-jamstack/5826/7) that they build their complex site with 7500 content pages in 13 seconds.
Some other example sites are [kubernetes.io](https://kubernetes.io/), [letsencrypt.org](https://gohugo.io/showcase/letsencrypt/), [support.1password.com](http://gohugo.io/showcase/1password-support/), [netlify.com](https://www.netlify.com), [litecoin.org](https://litecoin.org/), and [forestry.io](https://forestry.io/).
{{< imgproc graph-stars Fit "600x400" >}}
Number of GitHub stars in relation to the Hugo release dates.
{{< /imgproc >}}
More numbers:
* 26800+ [stars](https://github.com/gohugoio/hugo/stargazers) on GitHub.
* 444+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) to the Hugo source repository, 654+ to [Hugo Docs](https://github.com/gohugoio/hugoDocs/graphs/contributors). [@bep](https://github.com/bep) is the most active with around 70% of the current code base (line count).
* 235+ [themes](https://themes.gohugo.io/)
* 50% increase in the number of user sessions on the [gohugo.io](https://gohugo.io/) web sites the last 12 months.[^2]
* Hugo build release binaries for [a myriad](https://github.com/gohugoio/hugo/releases/tag/v0.42.2) of platforms. And since it can also be installed from Chocolatey on Windows, Brew on MacOs, Snap on Linux and `apt-get` on Debian/Ubuntu, it is impossible to give accurate download numbers. But the number is not small.
## Hugo Next
We're not finished with Hugo, but Hugo `0.43` very nicely wraps up the first five years. It started out as a small and fast static site generator. It is now [even faster](https://forestry.io/blog/hugo-vs-jekyll-benchmark/), and now so loaded with features that it has grown out of being just a "static site generator". It is a _framework for building websites_.
My interest in Hugo started on the Sunday when I moved my blog, [bepsays.com](https://bepsays.com/en/), twice. The second static generator choice of that day, Hugo, was a good match. I remember Steve being very enthusiastic about getting patches with fixes and enhancements, and I was eventually taken over by the simplicity and power of Go, the programming language, and started to implement lots of new features.
My goal with all of this, if there is one, is to get a single binary with native and really fast implementations of the complete stack I need for web development and content editing. The single binary takes most of the pain out of installation and upgrades (if you stick with the same binary, it will continue to just work for decades).
**With 0.43, we are almost there.** With that release, it should be possible to set up a Hugo-only project without any additional tools (Gulp, WebPack) for all aspects of website building. There will still be situations where those tools will still be needed, of course, but we will continue to fill the gaps in the feature set.
Hugo has stuck with the sub-zero versions to signal active development, with a new main release every 5-6 weeks. But we take stability very seriously (breaking things add lots of support work, we don't like that) and most site upgrades are [smooth](https://twitter.com/tmmx/status/1006288444459503616). But we are closing in on the first major stable version.
### The Road to 1.0
We have some more technical tasks that needs to be done (there is ongoing work to get the page quries into a more consistent state, also a simpler `.GetPage` method), but also some cool new functionality. The following roadmap is taken from memory, and may not be complete, but should be a good indication of what's ahead.
Pages from "other data sources"
: Currently, in addition to Hugo's list pages, every URL must be backed by a content file (Markdown, HTML etc.). This covers most use cases, but we need a flexible way to generate pages from other data sources. Think product catalogues and similar.
Upgrade Blackfriday to v2
: [Blackfriday](https://github.com/russross/blackfriday) is the main content renderer in Hugo. It has been rewritten to a more flexible architecture, which should allow us to fix some of the current shortcomings.
We should be able to create a better and easier-to-use data structure from the rendered content: Summary, the content after the summary, being able to range over the footnotes and the ToC. Having ToC as a proper data structure also open up a few other potential uses; using it as an index in [Related Content](https://gohugo.io/content-management/related/) would be one example.
This should also enable us to _do more_ with [Custom Output Formats](/templates/output-formats). It is already very powerful. GettyPubs are using it in [Quire](https://github.com/gettypubs/quire) to build [beautiful multi-platform publications](http://www.getty.edu/publications/digital/digitalpubs.html). But it can be improved. For rendering of content files, you are currently restricted to HTML. It would be great if we could configure alternative renderers per output format, such as LaTeX and EPUB.
Related to this is also to add a configurable "Markdown URL rewriter", which should make more portable URLs in Markdown, e.g. image links that work both when viewed on GitHub and your published site.
### The Road to the Future
These are the items that first comes to mind if you ask me to think even further ahead:
Dependency manager for Theme Components
: In Hugo `0.42` we added [Theme Components](/themes/theme-components/) and Theme Inheritance. With SCSS support in Hugo `0.43`, which also follows the same project/themes precedence order (add `_variables.scss` to your project, configure SASS colour variables in `config.toml`), we have a solid foundation for creating easy to use and extensible themes. But we are missing some infrastructure around this. We have a site with 235+ [themes](https://themes.gohugo.io/)[^themes] listed, but you currently need to do some added work to get the theme up and running for your site. In the Go world, we don't have NPM to use, which is a curse and a blessing, but I have some ideas about building a simple dependency manager into Hugo, modelled after how Go is doing it (`hugo install`). You should be able to configure what theme and theme components you want to use, and Hugo should handle the installation of the correct versions. This should make it easier for the user, but it would also enable community driven and even commercial "theme stores".
{{< imgproc graph-themes Fit "600x400" >}}
Number of Hugo themes on themes.gohugo.io in relation to the Hugo release dates.
{{< /imgproc >}}
The "New York Times on Hugo" Use Case
: There are recurring questions on the support forum from [really big sites](https://discourse.gohugo.io/t/transition-2m-posts-from-wordpress-to-hugo/12704) that want to move to Hugo. There are many [good reasons](https://www.netlify.com/blog/2016/05/18/9-reasons-your-site-should-be-static/) why they want this (security, cost-saving, EU regulations etc.). And while there have been reports about companies building 600 000 pages with Hugo on very powerful hardware, we will have to rethink the build model to make this usable. Keywords are: streaming builds, segmented builds, partial rebuilds. There are other site generators also talking about this. It should be possible, and my instinct tells me that it should be easier to do when your starting point is "really fast". But this is not a small weekend project for me, and I have already talked to several companies about sponsoring this.
Plugins
: A Theme Component could also be called a plugin. But there are several potential plugin hooks into Hugo's build pipeline: Resource transformations, content rendering etc. We will eventually get there, but we should do it without giving up too much of the Hugo speed and simplicity.
## Thanks
So, thanks to everyone who have contributed to getting Hugo where it is today. It is hard to single out individuals, but a big shout-out to all the Hugo experts and moderators helping out making the [discourse.gohugo.io](https://discourse.gohugo.io/) a very active and possibly one of the best support forums out there.
And the last shout-out goes to two maintainers who have been there more or less from the start. [@digitalcraftsman](https://github.com/digitalcraftsman/) has been doing a fantastic job keeping the fast growing theme site and [repository](https://github.com/gohugoio/hugoThemes) in pristine condition. I have it on my watch list, but that is just out of curiosity. There are lots of activity, but it runs as clock work. [Anthony Fok](https://github.com/anthonyfok) has contributed with a variety of things but is most notable as the Linux expert on the team. He manages the Debian build and is the one to thank for up-to-date binaries on Debian and Ubuntu.
One final note: If you have not done so already, please visit [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) and push the "star button".
Gopher artwork by [Ashley McNamara](https://github.com/ashleymcnamara/gophers/) (licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)). Inspired by [Renee French](https://reneefrench.blogspot.com/).
[^2]: Numbers from Google Analytics. The Hugo websites are https://discourse.gohugo.io/, https://gohugo.io/ and https://themes.gohugo.io/. It is rumoured that when [Matt Biilman](https://twitter.com/biilmann?lang=en), CEO and Co-founder of Netlify, opened the first power bill after sponsoring Hugo's hosting, said: "Du må lave fis med mig, those Hugo sites have lots of web traffic!"
[^sgen]: That was at the time of writing this article. _Next_, a React based static site generator, has momentum and is closing in on Hugo's 2nd place.
[^themes]: We pull all the themes from GitHub and build the theme site and 235 demo sites on Netlify in 4 minutes. And that is impressing.

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View file

@ -43,6 +43,16 @@
Blackfriday flag: **`HTML_HREF_TARGET_BLANK`** <br> Blackfriday flag: **`HTML_HREF_TARGET_BLANK`** <br>
Purpose: `true` opens <s>external links</s> **absolute** links in a new window or tab. While the `target="_blank"` attribute is typically used for external links, Blackfriday does that for _all_ absolute links ([ref](https://discourse.gohugo.io/t/internal-links-in-same-tab-external-links-in-new-tab/11048/8)). One needs to make note of this if they use absolute links throughout, for internal links too (for example, by setting `canonifyURLs` to `true` or via `absURL`). Purpose: `true` opens <s>external links</s> **absolute** links in a new window or tab. While the `target="_blank"` attribute is typically used for external links, Blackfriday does that for _all_ absolute links ([ref](https://discourse.gohugo.io/t/internal-links-in-same-tab-external-links-in-new-tab/11048/8)). One needs to make note of this if they use absolute links throughout, for internal links too (for example, by setting `canonifyURLs` to `true` or via `absURL`).
`nofollowLinks`
: default: **`false`** <br>
Blackfriday flag: **`HTML_NOFOLLOW_LINKS`** <br>
Purpose: `true` creates <s>external links</s> **absolute** links with `nofollow` being added to their `rel` attribute. Thereby crawlers are advised to not follow the link. While the `rel="nofollow"` attribute is typically used for external links, Blackfriday does that for _all_ absolute links. One needs to make note of this if they use absolute links throughout, for internal links too (for example, by setting `canonifyURLs` to `true` or via `absURL`).
`noreferrerLinks`
: default: **`false`** <br>
Blackfriday flag: **`HTML_NOREFERRER_LINKS`** <br>
Purpose: `true` creates <s>external links</s> **absolute** links with `noreferrer` being added to their `rel` attribute. Thus when following the link no referrer information will be leaked. While the `rel="noreferrer"` attribute is typically used for external links, Blackfriday does that for _all_ absolute links. One needs to make note of this if they use absolute links throughout, for internal links too (for example, by setting `canonifyURLs` to `true` or via `absURL`).
`plainIDAnchors` `plainIDAnchors`
: default **`true`** <br> : default **`true`** <br>
Blackfriday flag: **`FootnoteAnchorPrefix` and `HeaderIDSuffix`** <br> Blackfriday flag: **`FootnoteAnchorPrefix` and `HeaderIDSuffix`** <br>

View file

@ -5,7 +5,7 @@ description: Hugo searches for the layout to use for a given page in a well defi
godocref: godocref:
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-05-25 lastmod: 2017-07-05
categories: [templates,fundamentals] categories: [templates,fundamentals]
keywords: [templates] keywords: [templates]
menu: menu:
@ -32,7 +32,7 @@ Output Format
: See [Custom Output Formats](/templates/output-formats). An output format has both a `name` (e.g. `rss`, `amp`, `html`) and a `suffix` (e.g. `xml`, `html`). We prefer matches with both (e.g. `index.amp.html`, but look for less specific templates. : See [Custom Output Formats](/templates/output-formats). An output format has both a `name` (e.g. `rss`, `amp`, `html`) and a `suffix` (e.g. `xml`, `html`). We prefer matches with both (e.g. `index.amp.html`, but look for less specific templates.
Language Language
: We will consider a language code in the template name. If the site language is `fr`, `index.fr.amp.html` will win over `index.amp.html`, but we will `index.amp.html` will be chosen before `index.fr.html`. : We will consider a language code in the template name. If the site language is `fr`, `index.fr.amp.html` will win over `index.amp.html`, but `index.amp.html` will be chosen before `index.fr.html`.
Layout Layout
: Can be set in page front matter. : Can be set in page front matter.
@ -58,14 +58,7 @@ Section
## Hugo Layouts Lookup Rules With Theme ## Hugo Layouts Lookup Rules With Theme
In Hugo, layouts can live in either the project's or theme's layout folder, and the most specific layout will be chosen. Hugo will interleave the lookups: In Hugo, layouts can live in either the project's or the themes' layout folders, and the most specific layout will be chosen. Hugo will interleave the lookups listed below, finding the most specific one either in the project or themes.
1. layouts/page/index.html
2. demoTheme/layouts/page/index.html
3. layouts/...
This way it is possible to override specific templates from the theme.
## Examples: Layout Lookup for Regular Pages ## Examples: Layout Lookup for Regular Pages

View file

@ -29,59 +29,44 @@ Hugo can initialize a new blank theme directory within your existing `themes` us
hugo new theme [name] hugo new theme [name]
``` ```
## Theme Components ## Theme Folders
A theme consists of templates and static assets such as javascript and css files. Themes can also provide [archetypes][], which are archetypal content types used by the `hugo new` command to scaffold new content files with preconfigured front matter. A theme component can provide files in one or more of the following standard Hugo folders:
layouts
: Templates used to render content in Hugo. Also see [Templates Lookup Order](/templates/lookup-order/).
static
: Static files, such as logos, CSS and JavaScript.
i18n
: Language bundles.
data
: Data files.
archetypes
: Content templates used in `hugo new`.
## Theme Configuration File
A theme component can also provide its own [Configuration File](/getting-started/configuration/), e.g. `config.toml`. There are some restrictions to what can be configured in a theme component, and it is not possible to overwrite settings in the project.
The following settings can be set:
* `params` (global and per language)
* `menu` (global and per language)
* `outputformats` and `mediatypes`
## Theme Description File
In addition to the configuration file, a theme can also provide a `theme.toml` file that describes the theme, the author and origin etc. See [Add Your Hugo Theme to the Showcase](/contribute/themes/).
{{% note "Use the Hugo Generator Tag" %}} {{% note "Use the Hugo Generator Tag" %}}
The [`.Hugo.Generator`](/variables/hugo/) tag is included in all themes featured in the [Hugo Themes Showcase](http://themes.gohugo.io). We ask that you include the generator tag in all sites and themes you create with Hugo to help the core team track Hugo's usage and popularity. The [`.Hugo.Generator`](/variables/hugo/) tag is included in all themes featured in the [Hugo Themes Showcase](http://themes.gohugo.io). We ask that you include the generator tag in all sites and themes you create with Hugo to help the core team track Hugo's usage and popularity.
{{% /note %}} {{% /note %}}
## Layouts
Hugo is built around the concept that things should be as simple as possible.
Fundamentally, website content is displayed in two different ways, a single
piece of content and a list of content items. With Hugo, a theme layout starts
with the defaults. As additional layouts are defined, they are used for the
content type or section they apply to. This keeps layouts simple, but permits
a large amount of flexibility.
## Single Content
The default single file layout is located at `layouts/_default/single.html`.
## List of Contents
The default list file layout is located at `layouts/_default/list.html`.
## Partial Templates
Theme creators should liberally use [partial templates](/templates/partials/)
throughout their theme files. Not only is a good DRY practice to include shared
code, but partials are a special template type that enables the themes end user
to be able to overwrite just a small piece of a file or inject code into the
theme from their local /layouts. These partial templates are perfect for easy
injection into the theme with minimal maintenance to ensure future
compatibility.
## Static
Everything in the static directory will be copied directly into the final site
when rendered. No structure is provided here to enable complete freedom. It is
common to organize the static content into:
```
/css
/js
/img
```
The actual structure is entirely up to you, the theme creator, on how you would like to organize your files.
## Archetypes
If your theme makes use of specific keys in the front matter, it is a good idea
to provide an archetype for each content type you have. [Read more about archetypes][archetypes].
[archetypes]: /content-management/archetypes/

View file

@ -1,80 +0,0 @@
---
title: Customize a Theme
linktitle: Customize a Theme
description: Customize a theme by overriding theme layouts and static assets in your top-level project directories.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [themes]
keywords: [themes, source, organization, directories]
menu:
docs:
parent: "themes"
weight: 20
weight: 20
sections_weight: 20
draft: false
aliases: [/themes/customize/]
toc: true
wip: true
---
The following are key concepts for Hugo site customization with themes. Hugo permits you to supplement *or* override any theme template or static file with files in your working directory.
{{% note %}}
When you use a theme cloned from its git repository, do not edit the theme's files directly. Instead, theme customization in Hugo is a matter of *overriding* the templates made available to you in a theme. This provides the added flexibility of tweaking a theme to meet your needs while staying current with a theme's upstream.
{{% /note %}}
## Override Static Files
There are times where you want to include static assets that differ from versions of the same asset that ships with a theme.
For example, a theme may use jQuery 1.8 in the following location:
```
/themes/<THEME>/static/js/jquery.min.js
```
You want to replace the version of jQuery that ships with the theme with the newer `jquery-3.1.1.js`. The easiest way to do this is to replace the file *with a file of the same name* in the same relative path in your project's root. Therefore, change `jquery-3.1.1.js` to `jquery.min.js` so that it is *identical* to the theme's version and place the file here:
```
/static/js/jquery.min.js
```
## Override Template Files
Anytime Hugo looks for a matching template, it will first check the working directory before looking in the theme directory. If you would like to modify a template, simply create that template in your local `layouts` directory.
The [template lookup order][lookup] explains the rules Hugo uses to determine which template to use for a given piece of content. Read and understand these rules carefully.
This is especially helpful when the theme creator used [partial templates][partials]. These partial templates are perfect for easy injection into the theme with minimal maintenance to ensure future compatibility.
For example:
```
/themes/<THEME>/layouts/_default/single.html
```
Would be overwritten by
```
/layouts/_default/single.html
```
{{% warning %}}
This only works for templates that Hugo "knows about" (i.e., that follow its convention for folder structure and naming). If a theme imports template files in a creatively named directory, Hugo wont know to look for the local `/layouts` first.
{{% /warning %}}
## Override Archetypes
If the archetype that ships with the theme for a given content type (or all content types) doesnt fit with how you are using the theme, feel free to copy it to your `/archetypes` directory and make modifications as you see fit.
{{% warning "Beware of `layouts/_default`" %}}
The `_default` directory is a very powerful force in Hugo, especially as it pertains to overwriting theme files. If a default file is located in the local [archetypes](/content-management/archetypes/) or layout directory (i.e., `archetypes/default.md` or `/layouts/_default/*.html`, respectively), it will override the file of the same name in the corresponding theme directory (i.e., `themes/<THEME>/archetypes/default.md` or `themes/<THEME>/layout/_defaults/*.html`, respectively).
It is usually better to override specific files; i.e. rather than using `layouts/_default/*.html` in your working directory.
{{% /warning %}}
[archetypes]: /content-management/archetypes/
[lookup]: /templates/lookup-order/
[partials]: /templates/partials/

View file

@ -0,0 +1,51 @@
---
title: Theme Components
linktitle: Theme Components
description: Hugo provides advanced theming support with Theme Components.
date: 2017-02-01
categories: [themes]
keywords: [themes, theme, source, organization, directories]
menu:
docs:
parent: "themes"
weight: 20
weight: 20
sections_weight: 20
draft: false
aliases: [/themes/customize/,/themes/customizing/]
toc: true
---
Since Hugo `0.42` a project can configure a theme as a composite of as many theme components you need:
{{< code-toggle file="config">}}
theme = ["my-shortcodes", "base-theme", "hyde"]
{{< /code-toggle >}}
You can even nest this, and have the theme component itself include theme components in its own `config.toml` (theme inheritance).[^1]
The theme definition example above in `config.toml` creates a theme with 3 theme components with precedence from left to right.
For any given file, data entry, etc., Hugo will look first in the project and then in `my-shortcode`, `base-theme`, and lastly `hyde`.
Hugo uses two different algorithms to merge the filesystems, depending on the file type:
* For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files.
* For `static`, `layouts` (templates), and `archetypes` files, these are merged on file level. So the left-most file will be chosen.
The name used in the `theme` definition above must match a folder in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`. There are plans to improve on this and get a URL scheme so this can be resolved automatically.
Also note that a component that is part of a theme can have its own configuration file, e.g. `config.toml`. There are currently some restrictions to what a theme component can configure:
* `params` (global and per language)
* `menu` (global and per language)
* `outputformats` and `mediatypes`
The same rules apply here: The left-most param/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts.
[^1]: Including theme components in the themes is currently not supported for themes hosted on [The Hugo Themes Site](https://themes.gohugo.io/), but can be really useful if you want to create your own theme based on a theme you find on that site.

View file

@ -1187,6 +1187,15 @@
"mkd" "mkd"
] ]
}, },
{
"Name": "plaintext",
"Aliases": [
"no-highlight",
"plain",
"text",
"txt"
]
},
{ {
"Name": "reStructuredText", "Name": "reStructuredText",
"Aliases": [ "Aliases": [
@ -1507,22 +1516,6 @@
"layouts/_default/single.html" "layouts/_default/single.html"
] ]
}, },
{
"Example": "Single page in \"posts\" section with theme",
"Kind": "page",
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
"layouts/posts/single.html.html",
"demoTheme/layouts/posts/single.html.html",
"layouts/posts/single.html",
"demoTheme/layouts/posts/single.html",
"layouts/_default/single.html.html",
"demoTheme/layouts/_default/single.html.html",
"layouts/_default/single.html",
"demoTheme/layouts/_default/single.html"
]
},
{ {
"Example": "AMP single page", "Example": "AMP single page",
"Kind": "page", "Kind": "page",
@ -1621,38 +1614,6 @@
"layouts/_default/list.html" "layouts/_default/list.html"
] ]
}, },
{
"Example": "Home page with theme",
"Kind": "home",
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
"layouts/index.html.html",
"demoTheme/layouts/index.html.html",
"layouts/home.html.html",
"demoTheme/layouts/home.html.html",
"layouts/list.html.html",
"demoTheme/layouts/list.html.html",
"layouts/index.html",
"demoTheme/layouts/index.html",
"layouts/home.html",
"demoTheme/layouts/home.html",
"layouts/list.html",
"demoTheme/layouts/list.html",
"layouts/_default/index.html.html",
"demoTheme/layouts/_default/index.html.html",
"layouts/_default/home.html.html",
"demoTheme/layouts/_default/home.html.html",
"layouts/_default/list.html.html",
"demoTheme/layouts/_default/list.html.html",
"layouts/_default/index.html",
"demoTheme/layouts/_default/index.html",
"layouts/_default/home.html",
"demoTheme/layouts/_default/home.html",
"layouts/_default/list.html",
"demoTheme/layouts/_default/list.html"
]
},
{ {
"Example": "AMP home, French language\"", "Example": "AMP home, French language\"",
"Kind": "home", "Kind": "home",
@ -1706,39 +1667,25 @@
] ]
}, },
{ {
"Example": "RSS home with theme", "Example": "RSS home",
"Kind": "home", "Kind": "home",
"OutputFormat": "RSS", "OutputFormat": "RSS",
"Suffix": "xml", "Suffix": "xml",
"Template Lookup Order": [ "Template Lookup Order": [
"layouts/index.rss.xml", "layouts/index.rss.xml",
"demoTheme/layouts/index.rss.xml",
"layouts/home.rss.xml", "layouts/home.rss.xml",
"demoTheme/layouts/home.rss.xml",
"layouts/rss.xml", "layouts/rss.xml",
"demoTheme/layouts/rss.xml",
"layouts/list.rss.xml", "layouts/list.rss.xml",
"demoTheme/layouts/list.rss.xml",
"layouts/index.xml", "layouts/index.xml",
"demoTheme/layouts/index.xml",
"layouts/home.xml", "layouts/home.xml",
"demoTheme/layouts/home.xml",
"layouts/list.xml", "layouts/list.xml",
"demoTheme/layouts/list.xml",
"layouts/_default/index.rss.xml", "layouts/_default/index.rss.xml",
"demoTheme/layouts/_default/index.rss.xml",
"layouts/_default/home.rss.xml", "layouts/_default/home.rss.xml",
"demoTheme/layouts/_default/home.rss.xml",
"layouts/_default/rss.xml", "layouts/_default/rss.xml",
"demoTheme/layouts/_default/rss.xml",
"layouts/_default/list.rss.xml", "layouts/_default/list.rss.xml",
"demoTheme/layouts/_default/list.rss.xml",
"layouts/_default/index.xml", "layouts/_default/index.xml",
"demoTheme/layouts/_default/index.xml",
"layouts/_default/home.xml", "layouts/_default/home.xml",
"demoTheme/layouts/_default/home.xml",
"layouts/_default/list.xml", "layouts/_default/list.xml",
"demoTheme/layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml" "layouts/_internal/_default/rss.xml"
] ]
}, },
@ -2978,6 +2925,24 @@
} }
}, },
"path": { "path": {
"Base": {
"Description": "",
"Args": null,
"Aliases": null,
"Examples": null
},
"Dir": {
"Description": "",
"Args": null,
"Aliases": null,
"Examples": null
},
"Ext": {
"Description": "",
"Args": null,
"Aliases": null,
"Examples": null
},
"Join": { "Join": {
"Description": "Join joins any number of path elements into a single path, adding a\nseparating slash if necessary. All the input\npath elements are passed into filepath.ToSlash converting any Windows slashes\nto forward slashes.\nThe result is Cleaned; in particular,\nall empty strings are ignored.", "Description": "Join joins any number of path elements into a single path, adding a\nseparating slash if necessary. All the input\npath elements are passed into filepath.ToSlash converting any Windows slashes\nto forward slashes.\nThe result is Cleaned; in particular,\nall empty strings are ignored.",
"Args": [ "Args": [
@ -2992,6 +2957,18 @@
[ [
"{{ path.Join \"my\" \"path\" \"filename.txt\" }}", "{{ path.Join \"my\" \"path\" \"filename.txt\" }}",
"my/path/filename.txt" "my/path/filename.txt"
],
[
"{{ \"my/path/filename.txt\" | path.Ext }}",
".txt"
],
[
"{{ \"my/path/filename.txt\" | path.Base }}",
"filename.txt"
],
[
"{{ \"my/path/filename.txt\" | path.Dir }}",
"my/path"
] ]
] ]
}, },
@ -3201,6 +3178,20 @@
"Aliases": null, "Aliases": null,
"Examples": null "Examples": null
}, },
"Repeat": {
"Description": "Repeat returns a new string consisting of count copies of the string s.",
"Args": [
"n",
"s"
],
"Aliases": null,
"Examples": [
[
"{{ \"yo\" | strings.Repeat 4 }}",
"yoyoyoyo"
]
]
},
"Replace": { "Replace": {
"Description": "Replace returns a copy of the string s with all occurrences of old replaced\nwith new.", "Description": "Replace returns a copy of the string s with all occurrences of old replaced\nwith new.",
"Args": [ "Args": [
@ -3230,6 +3221,14 @@
], ],
"Examples": [] "Examples": []
}, },
"RuneCount": {
"Description": "RuneCount returns the number of runes in s.",
"Args": [
"s"
],
"Aliases": null,
"Examples": []
},
"SliceString": { "SliceString": {
"Description": "SliceString slices a string by specifying a half-open range with\ntwo indices, start and end. 1 and 4 creates a slice including elements 1 through 3.\nThe end index can be omitted, it defaults to the string's length.", "Description": "SliceString slices a string by specifying a half-open range with\ntwo indices, start and end. 1 and 4 creates a slice including elements 1 through 3.\nThe end index can be omitted, it defaults to the string's length.",
"Args": [ "Args": [

View file

@ -1,4 +1,4 @@
{{ $original := .Page.Resources.GetMatch (printf "%s*" (.Get 0)) }} {{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
{{ $command := .Get 1 }} {{ $command := .Get 1 }}
{{ $options := .Get 2 }} {{ $options := .Get 2 }}
{{ if eq $command "Fit"}} {{ if eq $command "Fit"}}
@ -11,8 +11,8 @@
{{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize."}} {{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize."}}
{{ end }} {{ end }}
{{ $image := .Scratch.Get "image" }} {{ $image := .Scratch.Get "image" }}
<figure style="width: {{ add $image.Width 3 }}px; padding: 3px; background-color: #cccc"> <figure style="padding: 0.25rem; margin: 2rem 0; background-color: #cccc">
<img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}"> <img style="max-width: 100%; height: auto;" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
<figcaption> <figcaption>
<small> <small>
{{ with .Inner }} {{ with .Inner }}

View file

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

View file

@ -12,7 +12,7 @@ hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('html', require('highlight.js/lib/languages/handlebars')); hljs.registerLanguage('html', require('highlight.js/lib/languages/handlebars'));
hljs.registerLanguage("go", function(e) { hljs.registerLanguage("go", function(e) {
var t = { keyword: "code output note warning break default func interface select case map struct chan else goto package switch const fallthrough if range end type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune id autoplay Get", literal: "file download copy true false iota nil Pages with", built_in: "append cap close complex highlight copy imag len make new panic print println real recover delete Site Data tweet speakerdeck youtube ref relref vimeo instagram gist figure innershortcode" }; var t = { keyword: "code output note warning break default func interface select case map struct chan else goto package switch const fallthrough if range end type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune id autoplay Get", literal: "file download copy true false iota nil Pages with", built_in: "append cap close complex highlight copy imag len make new panic print println real recover delete Site Data tweet youtube ref relref vimeo instagram gist figure innershortcode" };
return { aliases: ["golang","hugo"], k: t, i: "</", c: [e.CLCM, e.CBCM, { cN: "string", v: [e.QSM, { b: "'", e: "[^\\\\]'" }, { b: "`", e: "`" }] }, { cN: "number", v: [{ b: e.CNR + "[dflsi]", r: 1 }, e.CNM] }, { b: /:=/ }, { cN: "function", bK: "func", e: /\s*\{/, eE: !0, c: [e.TM, { cN: "params", b: /\(/, e: /\)/, k: t, i: /["']/ }] }] } return { aliases: ["golang","hugo"], k: t, i: "</", c: [e.CLCM, e.CBCM, { cN: "string", v: [e.QSM, { b: "'", e: "[^\\\\]'" }, { b: "`", e: "`" }] }, { cN: "number", v: [{ b: e.CNR + "[dflsi]", r: 1 }, e.CNM] }, { b: /:=/ }, { cN: "function", bK: "func", e: /\s*\{/, eE: !0, c: [e.TM, { cN: "params", b: /\(/, e: /\)/, k: t, i: /["']/ }] }] }
}); });