Commit graph

4422 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
3eb313fef4 Simplify .Site.GetPage etc.
This commit is a follow up to a recent overhaul of the GetPage/ref/relref implemenation.

The most important change in this commit is the update to `.Site.GetPage`:

* To reduce the amount of breakage in the wild to its minimum, I have reworked .Site.GetPage with some rules:

* We cannot support more than 2 arguments, i.e. .Site.GetPage "page" "posts" "mypage.md" will now throw an error. I think this is the most uncommon syntax and should be OK. It is an easy fix to change the above to .Site.GetPage "/posts/mypage.md" or similar.
* .Site.GetPage "home", .Site.GetPage "home" "" and .Site.GetPage "home" "/" will give you the home page. This means that if you have page in root with the name home.md you need to do .Site.GetPage "/home.md" or similar

This commit also fixes some multilingual issues, most notable it is now possible to do cross-language ref/relref lookups by prepending the language code to the path, e.g. `/jp/posts/mypage.md`.

This commit also reverts the site building tests related to this to "Hugo 0.44 state", to get better control of the changes made.

Closes #4147
Closes #4727
Closes #4728
Closes #4728
Closes #4726
Closes #4652
2018-07-18 00:07:20 +02:00
Vas Sudanagunta
b93417aa1d Unify page lookups
This commit unifies the core internal page index for all page kinds.

This enables the `ref` and `relref` shortcodes to support all pages kinds, and adds a new page-relative  `.GetPage` method with simplified signature.

See #4147
See #4727
See #4728
See #4728
See #4726
See #4652
2018-07-18 00:07:20 +02:00
Lucas Bickel
fd1f4a7860 Fix addkit link to account for i18n 2018-07-16 21:23:27 +02:00
Bjørn Erik Pedersen
4c240800a4
resource/bundler: Improve error message 2018-07-16 10:42:07 +02:00
Garry McNulty
38204c4ab6 hugolib: Only set 'allThemes' if there are themes in the config file
When the 'allThemes' configuration setting is read, it will panic if
there are no themes. This was a regression introduced in Hugo 0.42.

Also updated a unit test to check for this.

Fixes #4851
2018-07-15 16:13:48 +02:00
Bjørn Erik Pedersen
2f2bc7ff70
resource/integrity: Remove unused code 2018-07-14 11:17:48 +02:00
Bjørn Erik Pedersen
242b297f57
releaser: Remove flag on Windows build 2018-07-13 08:40:09 +02:00
hugoreleaser
f44c9ab9cd releaser: Prepare repository for 0.45-DEV
[ci skip]
2018-07-13 06:05:41 +00:00
hugoreleaser
9f9695cf7b releaser: Add release notes to /docs for release of 0.44
[ci skip]
2018-07-13 06:03:09 +00:00
hugoreleaser
0831d8ccaf releaser: Bump versions for release of 0.44
[ci skip]
2018-07-13 06:03:09 +00:00
Bjørn Erik Pedersen
1d4ff024ca
Finish release notes 0.44 2018-07-13 07:53:33 +02:00
hugoreleaser
521e63ac7c releaser: Add release notes draft for 0.44
Rename to *-ready.md to continue. [ci skip]
2018-07-13 05:27:58 +00:00
Bjørn Erik Pedersen
47d38628ec resource: Clean up the in-memory Resource reader usage
Turns out `strings.Reader` implements both `io.Reader` and `io.Seeker`, so we don't need anything special.

Updates #4936
2018-07-12 21:32:52 +02:00
Bjørn Erik Pedersen
0024dcfe3e resource: Move opening of the transformed resources after cache check
The old version should be functionally the same, but opening up these readers (potentially files) every time is wasteful if we don't read from them.
2018-07-12 19:36:12 +02:00
Bjørn Erik Pedersen
beec1fc98e resource: Fix resources.Concat for transformed resources
Fixes #4936
2018-07-12 19:36:12 +02:00
Bjørn Erik Pedersen
306573def0 Improve type support in resources.Concat
This allows the result of `.Resources.Match` and similar to be concatenated.

Fixes #4934
2018-07-12 13:43:27 +02:00
Bjørn Erik Pedersen
80c8f3b81a hugolib: Fix static filesystem for themed multihost sites
Multihost is where each language has its own `baseURL`. In this configuration, static files from the theme was not picked up.

This was a regression in Hugo `0.42`. This commit also adds proper tests for this, so that does not happen again.

Fixes #4929
2018-07-12 12:18:56 +02:00
Bjørn Erik Pedersen
6b6dcb44a0 Flush partialCached cache on rebuilds
Fixes #4931
2018-07-11 20:40:04 +02:00
Bjørn Erik Pedersen
d96f2a460f
resource: Include the transformation step in the error message
Fixes #4924
2018-07-11 11:03:15 +02:00
Bjørn Erik Pedersen
ac53035030
media: Only show deprecation warning when needed
Fixes #4927
2018-07-10 23:21:48 +02:00
Bjørn Erik Pedersen
b874a1ba7a media: Allow multiple file suffixes per media type
Before this commit, `Suffix` on `MediaType` was used both to set a custom file suffix and as a way to augment the mediatype definition (what you see after the "+", e.g. "image/svg+xml").

This had its limitations. For one, it was only possible with one file extension per MIME type.

Now you can specify multiple file suffixes using "suffixes", but you need to specify the full MIME type
identifier:

[mediaTypes]
[mediaTypes."image/svg+xml"]
suffixes = ["svg", "abc ]

In most cases, it will be enough to just change:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffix = "txt"

To:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffixes = ["txt"]

Hugo will still respect values set in "suffix" if no value for "suffixes" is provided, but this will be removed in a future release.

Note that you can still get the Media Type's suffix from a template: {{ $mediaType.Suffix }}. But this will now map to the MIME type filename.

Fixes #4920
2018-07-10 22:13:52 +02:00
Anthony Fok
4108705934 hugolib: Remove empty resources/ dir after TestNewSiteDefaultLang 2018-07-10 09:01:54 +02:00
Anthony Fok
9c1e82085e
.gitattributes: Exclude *.svg from CRLF/LF conversion
I ran into trouble after importing the Hugo v0.43 release tarball
into the Debian packaging git repository...
2018-07-09 21:06:15 -06:00
Anthony Fok
2b73e89d6d
tpl: Set permission of embedded templates to 0644 2018-07-09 12:57:08 -06:00
Bjørn Erik Pedersen
febf0aec8b
Build a fully static Windows extended binary 2018-07-09 20:42:08 +02:00
Bjørn Erik Pedersen
a4fad5be6b
Adjust release notes
[ci skip]
2018-07-09 12:11:57 +02:00
hugoreleaser
6084f0433c releaser: Prepare repository for 0.44-DEV
[ci skip]
2018-07-09 10:03:30 +00:00
hugoreleaser
cbb7214b6c releaser: Add release notes to /docs for release of 0.43
[ci skip]
2018-07-09 10:00:04 +00:00
hugoreleaser
e6136b36f3 releaser: Bump versions for release of 0.43
[ci skip]
2018-07-09 10:00:04 +00:00
Bjørn Erik Pedersen
659917a002
releaser: Revert to the old versions of the release pipeline 2018-07-09 11:54:10 +02:00
hugoreleaser
9d194ab904
releaser: Add release for 0.43 2018-07-09 10:52:02 +02:00
Anthony Fok
a305609e18
snap: Migrate from deprecated keywords to "override-build"
Also add verbosity and echo messages to aid debugging.

See #4908
2018-07-09 02:41:10 -06:00
Bjørn Erik Pedersen
179de5f5bc
Revert "Consider root and current section's content type if set in front matter"
This reverts commit c790029e1d.
2018-07-09 10:29:18 +02:00
Bjørn Erik Pedersen
5dc1f95b63
Revert "Restrict the new type layout resolution to page and section kinds"
This reverts commit 78e8a744b3.
2018-07-09 10:29:16 +02:00
Bjørn Erik Pedersen
6bc892fc24
Revert "output: gofmt -l -w output/layout.go"
This reverts commit f465571b33.
2018-07-09 10:29:13 +02:00
Bjørn Erik Pedersen
5f06dbf779
Revert "snap: Build both hugo and hugo.extended for 0.43"
This reverts commit e1027c5846.
2018-07-09 09:45:18 +02:00
Bjørn Erik Pedersen
0850e97984
Revert "Revert "Add Goreleaser extended config""
I reverted the wrong commit.

This reverts commit a3b4b10f65.
2018-07-09 09:44:51 +02:00
Bjørn Erik Pedersen
a3b4b10f65
Revert "Add Goreleaser extended config"
@anthonyfok we need to discuss how we want the Snap build to look before we implement it. I don't think this is how.

People who want SCSS builds can download from the release page for this release.

This reverts commit 626afc9825.
2018-07-09 09:30:10 +02:00
Bjørn Erik Pedersen
e3df6478f0
Bump CircleCI image 2018-07-09 09:24:34 +02:00
Bjørn Erik Pedersen
626afc9825
Add Goreleaser extended config
See #4908
2018-07-09 09:24:34 +02:00
Anthony Fok
e1027c5846
snap: Build both hugo and hugo.extended for 0.43
Due to snap's design, the name "hugo_extended" needs to be created
via an automatic alias request, see
https://forum.snapcraft.io/t/hugo-auto-alias-request-for-hugo-extended-hugo-extended/6297

Also migrate from deprecated "prepare", "build" and "install" keywords
to "override-build".

See #4908
2018-07-09 01:15:21 -06:00
Carlos Alexandro Becker
e1a052ecb8 fix: nfpm replacements
refs https://github.com/goreleaser/goreleaser/issues/715
2018-07-09 08:06:13 +02:00
Bjørn Erik Pedersen
bfc3488b8e
Add temporary build script 2018-07-08 16:08:22 +02:00
Anthony Fok
ce84b524f4 Add "extended" to "hugo version"
Fixes #4913
2018-07-08 11:08:54 +02:00
Yang Li
3cea2932e1 Fix typos 2018-07-07 12:29:56 +02:00
Bjørn Erik Pedersen
0efd374805
Merge commit '98293eaa1570b5aff4452021c8b6d6c8560b3f06' 2018-07-06 17:53:17 +02:00
Bjørn Erik Pedersen
98293eaa15 Squashed 'docs/' changes from 501c6e233..f59b3ab06
f59b3ab06 Fix typo in template lookup order
1e5536d6c Mutlilingual: Document "content directory per language" system (#509)
849a86048 Update index.md
0c24d229b Polish Hugo Next
a4c9b0ee2 Polish
bbec2c76e Some more in birthday post
fc9681e21 More on contributors
09fe3ea31 Some more on the birthday post
8da357240 Content and images for the 5th birthday blog post
fb45bb8dc Add draft for anniversary blog post
4666d0a18 Release 0.42.2
9b74d286a Merge branch 'temp422'
354e7b66b releaser: Add release notes to /docs for release of 0.42.2
57a617f34 releaser: Bump versions for release of 0.42.2
ccc3ac1b8 Update errorf.md
35706c21a Update errorf.md
1c0f35fd1 Update errorf.md
b6170774b Add syntax highlighting gallery links for Chroma
f91d9da47 Update usage.md
c9a8f0190 Improve theme components documentation
3c4e39ddd Release 0.42.1
b45eb453f Merge branch 'temp421'
c74682a10 releaser: Prepare repository for 0.43-DEV
321e07fa5 releaser: Add release notes to /docs for release of 0.42.1
7154271e0 releaser: Bump versions for release of 0.42.1
360d8244f Add link to Privacy Config
1f2454247 Fix typo
a8f5f994e Fix typo
d9f3f078c Update simple variants documentation (#500)
f5cfd44e0 Release 0.42
fe604b321 releaser: Prepare repository for 0.43-DEV
c3e5b3ca0 releaser: Add release notes to /docs for release of 0.42
3174d1b37 releaser: Bump versions for release of 0.42
48cc2d51f docs: Update theme documentation
1922fb1a6 docs: Remove some files now moved
d7e4c453a Merge commit 'b239595af5a9fc1fc9a1ccc666c3ab06ccc32f04'
c40964c1b tplimpl: Remove speakerdeck shortcode
081f8a0f9 tpl/strings: strings.RuneCount
828ea5f15 tpl: Add strings.Repeat
a6b9f654a Add a BlackFriday option for rel="noreferrer" on external links
edb786516 Add a BlackFriday option for rel="nofollow" on external links
e4374971f releaser: Prepare repository for 0.42-DEV

git-subtree-dir: docs
git-subtree-split: f59b3ab06f282c26bce07263c8be6672cf8f7969
2018-07-06 17:52:13 +02:00
Bjørn Erik Pedersen
2b8d907ab7 Add a newScratch template func
Fixes #4685
2018-07-06 17:51:38 +02:00
Bjørn Erik Pedersen
43338c3a99 hugolib: Do not create paginator pages for the other output formats
This is a recent regression in Hugo, where we have started to produce `/page/30/index.json` when the main output format (usually `HTML`) is set up with pagination.

For JSON this is potentially lot of superflous work and hurts performance.

This commit reinstates the earlier behaviour: We only create paginators if in use in the main output format.

And add a test for it to prevent this from happening again.

Fixes #4890
2018-07-06 14:01:27 +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