hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

theme-components.md (2454B)

    1 ---
    2 title: Theme Components
    3 linktitle: Theme Components
    4 description: Hugo provides advanced theming support with Theme Components.
    5 date: 2017-02-01
    6 categories: [hugo modules]
    7 keywords: [themes, theme, source, organization, directories]
    8 menu:
    9   docs:
   10     parent: "modules"
   11     weight: 50
   12 weight: 50
   13 sections_weight: 50
   14 draft: false
   15 aliases: [/themes/customize/,/themes/customizing/]
   16 toc: true
   17 ---
   18 
   19 {{% note %}}
   20 This section contain information that may be outdated and is in the process of being rewritten.
   21 {{% /note %}}
   22 Since Hugo `0.42` a project can configure a theme as a composite of as many theme components you need:
   23 
   24 {{< code-toggle file="config">}}
   25 theme = ["my-shortcodes", "base-theme", "hyde"]
   26 {{< /code-toggle >}}
   27 
   28 
   29 You can even nest this, and have the theme component itself include theme components in its own `config.toml` (theme inheritance).[^1]
   30 
   31 The theme definition example above in `config.toml` creates a theme with 3 theme components with precedence from left to right.
   32 
   33 For any given file, data entry, etc., Hugo will look first in the project and then in `my-shortcode`, `base-theme`, and lastly `hyde`.
   34 
   35 Hugo uses two different algorithms to merge the filesystems, depending on the file type:
   36 
   37 * For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files.
   38 * For `static`, `layouts` (templates), and `archetypes` files, these are merged on file level. So the left-most file will be chosen.
   39 
   40 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.
   41 
   42 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:
   43 
   44 * `params` (global and per language)
   45 * `menu` (global and per language)
   46 * `outputformats` and `mediatypes`
   47 
   48 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.
   49 
   50 
   51 [^1]: For themes hosted on the [Hugo Themes Showcase](https://themes.gohugo.io/) components need to be added as git submodules that point to the directory `exampleSite/themes` 
   52 
   53 
   54