Commit graph

12 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
34ee27a78b
commands: Do not fail server build when /static is missing
This was a un-intended change in Hugo 0.42. Most sites will have a static directory so this should not be a big issue, but this commit will revert back to old behaviour.

Fixes #4846
2018-06-13 08:48:20 +02:00
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
Bjørn Erik Pedersen
f21b827f7b
commands: Re-add the missing releaser command 2018-04-16 08:23:32 +02:00
Bjørn Erik Pedersen
1b4e0c4161 commands: Remove accidental and breaking space in baseURL flag
And added key-trimming to prevent future mishaps.

See #4607
2018-04-15 11:20:04 +02:00
Bjørn Erik Pedersen
27a524b090 commands: Properly handle CLI slice arguments
Like `--disableKinds` -- this handling was kind of broken when we recently moved this from global vars

See #4607
2018-04-14 11:32:25 +02:00
Bjørn Erik Pedersen
bede93de00 commands: Correctly handle destination and i18n-warnings
And add some more CLI tests.

See #4607
2018-04-14 11:32:25 +02:00
Bjørn Erik Pedersen
2aab6dee85 commands: Fix handling of persistent CLI flags
See #4607
2018-04-13 09:08:49 +02:00
Bjørn Erik Pedersen
96689a5c31
commands: Make commands.Execute return a Response object
We have no global `Hugo` object no more (yay!), and there are some external tools that depends on that value.

These tools need to use get that value from `Response.Result`.

Note that `commands.Execute` now also takes the arguments as a string slice. This should also make it easier to use, not having to modify `os.Args`.

This commit also wraps up this particular issue. Phew!

Test coverage in /commands before: 14.4%
Now:  53.5%

Still work to do, now it is at least possible.

Closes #4598
2018-04-11 20:37:08 +02:00
Bjørn Erik Pedersen
f396cffa23
commands: Fix the config command
It now also accepts the `-s` (source) flag.

See #4598
2018-04-11 10:09:45 +02:00
Bjørn Erik Pedersen
b110d0ae04
commands: Remove the Hugo global
There are still some cleaning to do, but that felt good.

See #4598
2018-04-11 09:50:19 +02:00
Bjørn Erik Pedersen
73825cfc1c
commands: Make the limit command work again
See #4598
2018-04-11 09:50:19 +02:00
Bjørn Erik Pedersen
e8d6ca9531
commands: Add CLI tests
See #4598
2018-04-11 09:50:19 +02:00