This commit fixes an issue introduced in the recently released Hugo 0.22.
This logic did not handle the case with root sections with non-section subfolders very well.
Fixes#3586
This enables both the variants below:
Current (first level only):
```
"blog": ":section/:title",
```
Nested (all levels):
```
"blog": ":sections/:title",
```
Should ideally been part of Hugo 0.22, but better late than never ...
Fixes#3580
This issue is more visible now that we support nested sections.
This commit makes operations like pasting new content folders or deleting content folders during server watch just work.
Fixes#3570
We still have go-toml as a transitive dependency, and it is the way to go eventually, but we care about speed, so let us wait that one out.
Note that the issue this fixes is about taxonomies, but I guess this is a general issue for sites with many pages that uses TOML as front matter.
```
benchmark old ns/op new ns/op delta
BenchmarkFrontmatterTags/TOML:1-4 23206 8543 -63.19%
BenchmarkFrontmatterTags/TOML:11-4 80117 18495 -76.92%
BenchmarkFrontmatterTags/TOML:21-4 140676 28727 -79.58%
benchmark old allocs new allocs delta
BenchmarkFrontmatterTags/TOML:1-4 173 60 -65.32%
BenchmarkFrontmatterTags/TOML:11-4 625 138 -77.92%
BenchmarkFrontmatterTags/TOML:21-4 1106 210 -81.01%
benchmark old bytes new bytes delta
BenchmarkFrontmatterTags/TOML:1-4 9231 2912 -68.45%
BenchmarkFrontmatterTags/TOML:11-4 19808 5184 -73.83%
BenchmarkFrontmatterTags/TOML:21-4 31200 7536 -75.85%
```
See #3541
Updates #3464
So you can do and get:
```
▶ ./benchSite.sh "YAML,num_pages=10"
Running with BenchmarkSiteBuilding/YAML,num_pages=10
BenchmarkSiteBuilding/YAML,num_pages=10-4 1000 1611261 ns/op 730749 B/op 6458 allocs/op
PASS
ok github.com/spf13/hugo/hugolib 8.168s
```
And change site benchmark separator to comma to make it Bash and regexp friendly, example:
./benchSite.sh "frontmatter=YAML,num_root_sections=1,num_pages=.*,tags_per_page=20,shortcodes=false,render=false"
To run a subset of these benchmark, one can do something like this:
```
go test -run="NONE" -bench="BenchmarkSiteBuilding/tags_per_page=0.*shortcodes=true.*render=false" -test.benchmem=true ./hugolib
```
Which will run without any tags, with shortcodes, but will skip rendering.
Fixes#3535
Looks to be slightly slower with the low number of section pages, but the 1000 regular pages seem to add value.
```
benchmark old ns/op new ns/op delta
BenchmarkGetPage-4 97.7 145 +48.41%
BenchmarkGetPageRegular-4 7933 161 -97.97%
benchmark old allocs new allocs delta
BenchmarkGetPage-4 0 0 +0.00%
BenchmarkGetPageRegular-4 0 0 +0.00%
benchmark old bytes new bytes delta
BenchmarkGetPage-4 0 0 +0.00%
BenchmarkGetPageRegular-4 0 0 +0.00%
```
When we know to look into the index pages collection, do that:
```
benchmark old ns/op new ns/op delta
BenchmarkGetPage-4 51483 7072 -86.26%
benchmark old allocs new allocs delta
BenchmarkGetPage-4 71 71 +0.00%
benchmark old bytes new bytes delta
BenchmarkGetPage-4 2648 2648 +0.00%
```
This commit also returns an error if .Site.GetPage is called with the regular Page Kind, as that is currently not supported.
Fixes#3503
A common use case for this is to redefine the built-in output format `RSS` to give it a different URL.
Before this commit, that was not possible without also providing an `outputs` definition.
Fixes#3447
This commit allows shortcode per output format, a typical use case would be the special AMP media tags.
Note that this will only re-render the "overridden" shortcodes and only in pages where these are used, so performance in the normal case should not suffer.
Closes#3220
This commit moves almost all of the template functions into separate
packages under tpl/ and adds a namespace framework. All changes should
be backward compatible for end users, as all existing function names in
the template funcMap are left intact.
Seq and DoArithmatic have been moved out of the helpers package and into
template namespaces.
Most of the tests involved have been refactored, and many new tests have
been written. There's still work to do, but this is a big improvement.
I got a little overzealous and added some new functions along the way:
- strings.Contains
- strings.ContainsAny
- strings.HasSuffix
- strings.TrimPrefix
- strings.TrimSuffix
Documentation is forthcoming.
Fixes#3042
Hugo 0.20 broke some sites that grouped their blog post and images together in subfolders.
This commit re-introduces that behaviour:
* If the file base name resolves to the same as the base name for the output type (i.e. "index" for HTML), the user probably meant it, so we treat that as an `uglyURL`, i.e. `my-blog-post-1.md`=> `/my-blog-post-1/index.html`
* The main use case for this is to group blog post and images together.
* Note that for the top level folder there will be a potential name conflict with a `section` `index.html` (if enabled)
* This issue will not be relevant for subfolders in sections
* Hugo will soon add support for nested sections, but we will have to find a way to separate them from the rest (`/content/_mysubsection` maybe).
Fixes#3396
This commit adds a work flow aroung GoReleaser to get the Hugo release process automated and more uniform:
* It can be run fully automated or in two steps to allow for manual edits of the relase notes.
* It supports both patch and full releases.
* It fetches author, issue, repo info. etc. for the release notes from GitHub.
* The file names produced are mainly the same as before, but we no use tar.gz as archive for all Unix versions.
* There isn't a fully automated CI setup in place yet, but the release tag is marked in the commit message with "[ci deploy]"
Fixes#3358
Partial rebuild does not have the same logic as normal rebuild on
selecting which file to build. This change makes it possible to
share the file select logic between two kinds of build.
Fix#3325.
This makes it consistent with how it behaves when it's set in config.toml.
This commit also unifies BaseURL in Site.Info so we now have one source for this value.
Fixes#3262
Before this commit, Hugo used `html/template` for all Go templates.
While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.
This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.
A couple of notes:
* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.
Fixes#3221
Having the content page name in the log key for the distinct error logger isnt't very usable when you have an error in a commonly used partial.
Using the Page Kind reduces the amount of log entries. Here is an example from an error in the partial menu.html, used in all the page templates:
```
Started building sites ...
ERROR 2017/04/02 12:19:43 Error while rendering "page": template: /Users/bep/sites/bepsays.com/layouts/_default/single.html:17:7: executing "/Users/bep/sites/bepsays.com/layouts/_default/single.html" at <partial "menu.html" ...>: error calling partial: template: partials/menu.html:9:11: executing "partials/menu.html" at <.DoesNotExist>: can't evaluate field DoesNotExist in type *hugolib.PageOutput
ERROR 2017/04/02 12:19:43 Error while rendering "section": template: /Users/bep/sites/bepsays.com/layouts/_default/section.html:17:7: executing "/Users/bep/sites/bepsays.com/layouts/_default/section.html" at <partial "menu.html" ...>: error calling partial: template: partials/menu.html:9:11: executing "partials/menu.html" at <.DoesNotExist>: can't evaluate field DoesNotExist in type *hugolib.PageOutput
ERROR 2017/04/02 12:19:43 Error while rendering "taxonomy": template: /Users/bep/sites/bepsays.com/layouts/_default/list.html:17:7: executing "/Users/bep/sites/bepsays.com/layouts/_default/list.html" at <partial "menu.html" ...>: error calling partial: template: partials/menu.html:9:11: executing "partials/menu.html" at <.DoesNotExist>: can't evaluate field DoesNotExist in type *hugolib.PageOutput
ERROR 2017/04/02 12:19:43 Error while rendering "home": template: /Users/bep/sites/bepsays.com/layouts/index.html:17:7: executing "/Users/bep/sites/bepsays.com/layouts/index.html" at <partial "menu.html" ...>: error calling partial: template: partials/menu.html:9:11: executing "partials/menu.html" at <.DoesNotExist>: can't evaluate field DoesNotExist in type *hugolib.PageOutput
ERROR 2017/04/02 12:19:43 Error while rendering "404": template: 404.html:2:3: executing "404.html" at <partial "menu.html" ...>: error calling partial: template: partials/menu.html:9:11: executing "partials/menu.html" at <.DoesNotExist>: can't evaluate field DoesNotExist in type *hugolib.PageOutput
Built site for language nn:
```
Which is pretty good.
Before this commit, Hugo used `html/template` for all Go templates.
While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.
This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.
A couple of notes:
* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.
Fixes#3221
Using it for list pages doesn't work and has potential weird side-effects.
The user probably meant to range over .Site.ReqularPages, and that is now marked clearly in the log.
Will have to fix this in a better way later in relation to the non-renderable pages.
But this commit brings the Hugo Benchmark down to "only slightly slower" than master.
```
benchmark old ns/op new ns/op delta
BenchmarkHugo-4 10074504521 10071236251 -0.03%
benchmark old allocs new allocs delta
BenchmarkHugo-4 43623091 49271859 +12.95%
benchmark old bytes new bytes delta
BenchmarkHugo-4 9468322704 9725848376 +2.72%
```
Which is something we can work with.
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done.
This commit's goal is to say:
* Every file target path is created by `createTargetPath`, i.e. one function for all.
* That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on.
* The path creation logic has full test coverage.
* All permalinks, paginator URLs etc. are then built on top of that same logic.
Fixes#1252Fixes#2110Closes#2374Fixes#1885Fixes#3102Fixes#3179Fixes#1641Fixes#1989
Changing it to PageOutput was a mistake. You may think that the increased parallelism should be a good thing.
But not so much with the increased lock contention and more complex concurrency model.
This commit fixes two different, but related issues:
1) Live-reload when a new shortcode was defined in the content file before the shortcode itself was created.
2) Live-reload when a newly defined shortcode changed its "inner content" status.
This commit also improves the shortcode related error messages to include the full path to the content file in question.
Fixes#3156
Lots of cleanups here:
- Refactor InterfaceToConfig and InterfaceToFrontMatter to use io.Writer.
- Simplify InterfaceToFrontMatter by wrapping InterfaceToConfig.
- Export FrontmatterType since we return it in DetectFrontMatter.
- Refactor removeTOMLIdentifier to avoid blindly replacing "+++".
- Update HandleJSONMetaData to return an empty map on nil input.
- Updates vendored goorgeous package and test for org-mode frontmatter.
- Add tests and godoc comments.
Coverage for parser package increased from 45.2% to 85.2%.
Previously this was left empty, but it is very handy to have a list
of term pages for a given taxonomy. This list can now be paginated
like other page lists. It makes it possible to render summary
content from each terms index page for instance. It also makes it
possible to sort the term pages in the same way that other page
lists can be sorted. An RSS feed is now generated for
KindTaxonomyTerm pages as well.
This also fixes a bug in HugoSites.createMissingPages. Previously
it would only check for existing KindTaxonomyTerm pages if the
taxonomy had any terms defined. So for a taxonomy with no terms
but a taxonomy terms page it would generate a second empty terms
page.
This relates to #3123.
The interfaces and types in `target` made sense at some point, but now this package is too restricted to a hardcoded set of media types.
The overall current logic:
* Create a file path based on some `Translator` with some hardcoded logic handling uglyURLs, hardcoded html suffix etc.
* In in some cases (alias), a template is applied to create the alias file.
* Then the content is written to destination.
One could argue that it is the last bullet that is the actual core responsibility.
This commit fixes that by moving the `hugolib`-related logic where it belong, and simplify the code, i.e. remove the abstractions.
This code will most certainly evolve once we start on #3123, but now it is at least possible to understand where to start.
Fixes#3123
Previously it would only check for existing KindTaxonomyTerm pages
if the taxonomy had any terms defined. So for a taxonomy with no terms
but a taxonomy terms page it would generate a second empty terms page.
When using the lazy blogger setting to automatically generate menu
entries from section pages, we now recognize section pages that have
content, and use the weight and linktitle configured in the frontmatter.
This way, we can use the lazy blogger automatic generation, and
influence menu order and translations, directly from the frontmatter.
Updates #2974
This commit makes sure that the `.Site.LastChange` is fetched from the latest page modification date.
Previously, this value was fetched from the last page in the default page sort, which may not be the last by date
if weight is set.
Fixes#2909Closes#2910
This fixes the behavior of .Truncated that was introduced with commit
bef496b97e which was later broken. The
desired behavior is that .Truncated would evaluate to false when there
was nothing after the user defined summary marker.
This also adds a simple unit test to ensure that this feature isn't
broken again. The check for content after the user defined summary
marker is done on the raw content instead of the working copy because
some of the markup renderers add elements after the marker, making it
difficult to determine if there is actually any content.
The behavior (evaluating to false when there is no content, just
summary) is also now documented.
The Param method currently assumes that its argument is a single,
distinct, top-level key to look up in the Params map. This enhances the
Param method; it will now also attempt to see if the key can be
interpreted as a nested chain of keys to look up in Params.
Fixes#2598
Add a new rssLimit site configuration option with default of 15. Prior
to this fix, you could create your own RSS feed to override the default
limit of 15, but we still had a hardcoded limit of 50 items set in
`hugolib.renderRSS()`.
With this option in place, the `range first 15 .Data.Pages` logic is no
longer hardcoded into the embedded RSS template.
Because the size of the slice passed to the template is now limited to
rssLimit instead of 50, this commit is a breaking change for sites
with a custom RSS template that expects more than 15 items.
Fixes#3035