Commit graph

590 commits

Author SHA1 Message Date
Anthony Fok
abc54080ec Add configFile(s) back to the watch list after REMOVE event
Fixes #4701
2018-08-16 16:11:57 +02:00
Bjørn Erik Pedersen
a655e00d70 commands: Gracefully handle typos in server config when running the server
Fixes #5081
2018-08-16 12:54:59 +02:00
Bjørn Erik Pedersen
e5052f4e09
commands: Include theme name in version mismatch error
Fixes #5044
2018-08-14 21:21:39 +02:00
Bjørn Erik Pedersen
789ef8c639
Add support for minification of final output
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar.

This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON.

To enable, run Hugo with the `--minify` flag:

```bash
hugo --minify
```

This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain.

Fixes #1251
2018-08-06 19:58:41 +02:00
Bjørn Erik Pedersen
062510cf1f
Get rid of the utils package 2018-07-22 00:35:09 +02:00
Bjørn Erik Pedersen
4e1d0cd9f1
Update hugo_windows.go 2018-07-22 00:09:46 +02:00
Bjørn Erik Pedersen
1b0aeeaaf0
commands: Disable flaky server tests on Windows CI 2018-07-18 09:43:31 +02:00
Bjørn Erik Pedersen
a4c513caeb
commands: Increase sleep in server teset to make it less shaky on Windows 2018-07-18 00:35:42 +02:00
Anthony Fok
ce84b524f4 Add "extended" to "hugo version"
Fixes #4913
2018-07-08 11:08:54 +02:00
Bjørn Erik Pedersen
dea71670c0
Add Hugo Piper with SCSS support and much more
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.

This commit adds

* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.

This means that you can now do this in your templates (or shortcodes):

```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```

This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:

```
HUGO_BUILD_TAGS=extended mage install
```

Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.

The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:

```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

The transformation funcs above have aliases, so it can be shortened to:

```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.

Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test

New functions to create `Resource` objects:

* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.

New `Resource` transformation funcs:

* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.

Fixes #4381
Fixes #4903
Fixes #4858
2018-07-06 11:46:12 +02:00
Bjørn Erik Pedersen
2955f93fc6
commands: Fix broken server-reload on config changes
This was accidently broken in Hugo 0.42.

Fixes #4878
2018-06-28 12:22:00 +02:00
openscript
fd71fa89bd Create missing head.html partial on new theme generation 2018-06-25 12:06:45 -06:00
openscript
b5a3aa7082 Add html doctype to baseof.html template for new themes 2018-06-25 12:06:45 -06:00
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
Anthony Fok
ed4a345efe commands: Create LICENSE rather than LICENSE.md in "new theme"
See also #4623
2018-06-11 10:40:22 +02:00
Anthony Fok
9717ac7dce commands: Create _default/baseof.html in "new theme"
Thanks to @digitalcraftsman, @bep and @rdwatters for providing the
actual content of the default baseof.html file.

Fixes #3576
2018-06-11 10:40:22 +02:00
Anthony Fok
692ec00872 commands: Make "new theme" feedback more intuitive 2018-06-11 10:40:22 +02:00
Anthony Fok
d3dd74fd65 commands: Move nextStepsText() to new_site.go 2018-06-11 10:40:22 +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
bf5f10faa9 Reset the "distinct error logger" on rebuilds
Fixes #4818
2018-06-05 10:45:24 +03:00
Bjørn Erik Pedersen
35ccf06dae
Fix some recently broken embedded templates
And add tests for them.

Fixes #4757
2018-05-23 10:03:11 +02:00
Lorenz Cuno Klopfenstein
568b4335c2 commands: Avoid ANSI character output on Windows
Fixes #4462
2018-05-22 17:15:19 +02:00
Anthony Fok
4eedb377b6
commands: Do not show empty BuildDate in version 2018-05-14 00:08:12 -06: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
9c782d5147
commands: Fix failing Travis server test 2018-04-12 09:31:53 +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
e7010c1b62
commands: Remove some TODOs
See #4598
2018-04-11 10:16:30 +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
24d5c21942
commands: Fix some flag diff
The CLI docs output is now identical with the master version.

See #4598
2018-04-11 09:57:43 +02:00
Bjørn Erik Pedersen
a7d00fc39e
commands: Add basic server test
See #4598
2018-04-11 09:51:07 +02:00
Bjørn Erik Pedersen
1e233b1c45
commands: Fix TestFixURL
See #4598
2018-04-11 09:50:19 +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
a8f7fbbb10
commands: Move the commands related logic to its own file
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
Bjørn Erik Pedersen
4d32f2fa89
commands: Make the hugo command non-global
See #4598
2018-04-11 09:50:19 +02:00
Bjørn Erik Pedersen
018602c46d
commands: Extract some common types into its own file
See #4598
2018-04-11 09:50:19 +02:00
Bjørn Erik Pedersen
2f0d98a19b
commands: Make the server command non-global
See #4598
2018-04-11 09:50:18 +02:00
Bjørn Erik Pedersen
e0621d207c
commands: Make the gen commands non-global
See #4598
2018-04-11 09:50:18 +02:00
Bjørn Erik Pedersen
e26a8b242a
commands: Make the list commands non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
2a2c983867
commands: Make the import commands non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
15b1e269ad
comands: Make the config command non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
56a1308044
commands: Make the new commands non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
4b780ca778
commands: Make convert command non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
7bc5e89fba
commands: Make more commands non-global
See #4598
2018-04-11 09:48:56 +02:00
Bjørn Erik Pedersen
fdf1d94ebc
commands: Make benchmark non-global
See #4598
2018-04-11 09:48:56 +02:00