2c0125b52 Remove .Site.Author 2cf8841b3 Update partialCached.md (#1924) 385487191 Update data-templates.md (#1926) ce207e141 Remove redundant markdown and fix a few typos (#1936) 3687c2953 Make heading id linkable, take 2 45c79bea7 Make heading id linkable b22079344 Delete duplicates the lines 557-569 and 570-582. (#1934) 0a90dc122 Rework the taxonomy variables page (#1935) 7f8979c50 Update theme 26e682a3a Update multilingual.md d40e7693f Update postcss.md 375d75c01 Update postcss npm instructions (#1931) 63020094a Emphasize Window shell selection (#1930) 56824be2c Update configuration.md b7b8f16b3 Docu 'Theme components': minor fix (#1929) 09dc81a05 Remove Docker from BSD page (#1927) 205fea204 netlify: Hugo 0.108.0 6abe49c28 Merge commit 'da670c38ee63a7fef25e2b9f42519232055b60dc' 12b59a4c5 docs: Add basic doc for wrapStandAloneImageWithinParagraph etc. ba07bd970 dartsass: Add sourceMapIncludeSources option git-subtree-dir: docs git-subtree-split: 2c0125b5290494d49334606c451446ebd9df3c21
2.4 KiB
title | linktitle | description | date | categories | keywords | menu | weight | sections_weight | draft | aliases | toc | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Theme Components | Theme Components | Hugo provides advanced theming support with Theme Components. | 2017-02-01 |
|
|
|
50 | 50 | false |
|
true |
{{% note %}}
This section contain information that may be outdated and is in the process of being rewritten.
{{% /note %}}
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-shortcodes
, base-theme
, and lastly hyde
.
Hugo uses two different algorithms to merge the filesystems, depending on the file type:
- For
i18n
anddata
files, Hugo merges deeply using the translation ID and data key inside the files. - For
static
,layouts
(templates), andarchetypes
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
andmediatypes
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.
-
For themes hosted on the Hugo Themes Showcase components need to be added as git submodules that point to the directory
exampleSite/themes
↩︎