hugo/hugolib
Bjørn Erik Pedersen 80230f26a3
Add support for theme composition and inheritance
This commit adds support for theme composition and inheritance in Hugo.

With this, it helps thinking about a theme as a set of ordered components:

```toml
theme = ["my-shortcodes", "base-theme", "hyde"]
```

The theme definition example above in `config.toml` creates a theme with the 3 components with presedence from left to right.

So, Hugo will, for any given file, data entry etc., 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.

A final note: Themes/components can also have a `theme` definition in their `config.toml` and similar, which is the "inheritance" part of this commit's title. This is currently not supported by the Hugo theme site. We will have to wait for some "auto dependency" feature to be implemented for that to happen, but this can be a powerful feature if you want to create your own theme-variant based on others.

Fixes #4460
Fixes #4450
2018-06-10 23:55:20 +02:00
..
filesystems Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
pagemeta
paths Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
testdata
testsite/content
404_test.go
alias.go
alias_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
author.go
case_insensitive_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
config.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
config_test.go Move the privacy config into a parent 2018-05-22 18:11:03 +02:00
datafiles_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
disableKinds_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
embedded_shortcodes_test.go tplimpl: Remove speakerdeck shortcode 2018-06-09 11:13:36 +02:00
embedded_templates_test.go tpl: Always load GA script over HTTPS 2018-06-09 23:47:44 +02:00
fileInfo.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
gitinfo.go
hugo_info.go
hugo_info_test.go
hugo_sites.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
hugo_sites_build.go Reset the "distinct error logger" on rebuilds 2018-06-05 10:45:24 +03:00
hugo_sites_build_failures_test.go hugolib: Fix freeze in invalid front matter error case 2018-03-24 10:06:58 +01:00
hugo_sites_build_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
hugo_sites_multihost_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
hugo_themes_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
language_content_dir_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
media.go
menu.go
menu_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
multilingual.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
orderedMap.go hugolib: Defer the unlock in orderedMap.Add 2018-04-22 21:32:05 +02:00
orderedMap_test.go hugolib: Process and render shortcodes in their order of appearance 2018-04-22 17:40:51 +02:00
page.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
page_bundler.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page_bundler_capture.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
page_bundler_capture_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
page_bundler_handlers.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
page_bundler_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
page_collections.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page_collections_test.go
page_output.go Fix some recently broken embedded templates 2018-05-23 10:03:11 +02:00
page_paths.go
page_paths_test.go
page_permalink_test.go
page_resource.go
page_taxonomy_test.go
page_test.go Fix .WordCount, .FuzzyWordCount, .ReadingTime when summary marker is set 2018-04-29 10:58:58 +02:00
page_time_integration_test.go
page_without_content.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pageCache.go
pageCache_test.go
pageGroup.go
pageGroup_test.go
pages_language_merge.go
pages_language_merge_test.go Add language merge support for Pages in resource.Resources 2018-04-19 16:23:00 +02:00
pages_related.go
pages_related_test.go
pageSort.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pageSort_test.go hugolib: Fix some shortcode vs .Content corner cases 2018-04-25 08:56:46 +02:00
pagesPrevNext.go
pagesPrevNext_test.go
pagination.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
pagination_test.go hugolib: Fix possible .Content cut 2018-05-08 16:52:51 +02:00
path_separators_test.go
permalinker.go
permalinks.go
permalinks_test.go
prune_resources.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
robotstxt_test.go
rss_test.go
scratch.go
scratch_test.go
shortcode.go hugolib: A little more on shortcode ordinal 2018-05-28 10:29:48 +02:00
shortcode_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
shortcodeparser.go Allow "*/" inside commented out shortcodes 2018-04-11 22:41:48 +02:00
shortcodeparser_test.go Allow "*/" inside commented out shortcodes 2018-04-11 22:41:48 +02:00
site.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
site_benchmark_test.go
site_output.go
site_output_test.go
site_render.go hugolib: Fix possible .Content cut 2018-05-08 16:52:51 +02:00
site_sections.go
site_sections_test.go
site_stats_test.go
site_test.go
site_url_test.go config: Add the foundation for GDPR privacy configuration 2018-05-21 00:41:42 +02:00
siteJSONEncode_test.go
sitemap.go
sitemap_test.go
taxonomy.go
taxonomy_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
template_engines_test.go
template_test.go
testhelpers_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
translations.go