Commit graph

1122 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
1f26420d39 hugolib: Support sub-sections in permalink settings
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
2017-06-13 11:42:32 +02:00
Bjørn Erik Pedersen
f1da5a15a3 hugolib: Make the RSS feed use the date for the node it represents
Closes #2708
2017-06-09 01:10:16 +02:00
Alexandros
d5ab7f087d Add noindex tag to HTML generated by Hugo Aliases
So that Googlebot can stop keeping the old URLs in the SERPs.
2017-06-08 23:12:39 +02:00
Bjørn Erik Pedersen
55dd533bf7 hugolib: Unexport some internal methods 2017-06-08 22:33:18 +02:00
Bjørn Erik Pedersen
fe901b8119 hugolib, commands: Improve live-reload on directory structure changes
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
2017-06-08 20:14:28 +02:00
Bjørn Erik Pedersen
b39689393c hugolib: Enable nested sections
Fixes #465
2017-06-08 11:21:34 +02:00
Bjørn Erik Pedersen
bef5048580 Revert "hugolib: Fix live-reload regression for add/removal of dirs"
Never mind. The "adding dir" scenario didn't work anyway, so that will need another fix.

This reverts commit 49a104309d.

Closes ##3325
2017-06-07 22:31:57 +02:00
Bjørn Erik Pedersen
49a104309d hugolib: Fix live-reload regression for add/removal of dirs
This reverts commit b5b6e81c02.

That change breaks watching of new directories (new dirs, deleted dirs).

Reopens #3325
Fixes #3569
2017-06-07 22:11:15 +02:00
Bjørn Erik Pedersen
5be0448635 hugolib: Fix disablePathToLower regression
Fixes #3374
2017-06-06 09:15:42 +02:00
Bjørn Erik Pedersen
1f55cb767d hugolib: Simplify some test loops 2017-06-06 08:43:33 +02:00
Bjørn Erik Pedersen
8aaec644a9 hugolib: Add test for no 404 in sitemap
Closes #3563
2017-06-06 08:09:25 +02:00
Bjørn Erik Pedersen
46b4607828 hugolib: Remove some superflous TODO comments 2017-06-03 17:32:47 +02:00
Bjørn Erik Pedersen
0907a5c1c2 all: Temporarily revert to BurntSushi for TOML front matter handling
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
2017-06-03 09:22:57 +02:00
Bjørn Erik Pedersen
250ebc1db5 hugolib: Add some more tags to benchmark 2017-06-02 18:40:10 +02:00
Bjørn Erik Pedersen
b37d959408 hugolib: Bump leaktest timeout to 30 seconds
To try to make it less flaky.
2017-06-02 16:50:44 +02:00
Bjørn Erik Pedersen
fdcfccedcb hugolib: Fix tag calculation in benchmark test 2017-06-02 09:13:45 +02:00
Bjørn Erik Pedersen
213ea74929 hugolib: Add number of tags as a benchmark know 2017-06-01 18:51:51 +02:00
Bjørn Erik Pedersen
08a10e5d14 hubolib: Make the site benchmark output more compact
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
```
2017-06-01 12:00:47 +02:00
Bjørn Erik Pedersen
9fa71c945e hubolib: Add 10k pages as a benchmark variant 2017-05-31 14:48:49 +03:00
Bjørn Erik Pedersen
d25d89e653 hugolib: Increase leaktest timeout
To try to less flaky test.
2017-05-31 13:23:22 +03:00
Bjørn Erik Pedersen
8969701967 hugolib: Break early from sitemap disabled check
See #3544
2017-05-31 12:55:51 +03:00
Bjørn Erik Pedersen
69d92dc49c hugolib: Respect disableKinds=["sitemap"]
Fixes #3544
2017-05-31 10:57:19 +03:00
Bjørn Erik Pedersen
d74452cfe8 Add benchSite.sh
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"
2017-05-31 10:35:02 +03:00
Bjørn Erik Pedersen
2342df4d2d hugolib: Add TOML/YAML switch to benchmark 2017-05-30 18:10:48 +03:00
Bjørn Erik Pedersen
828427ef52 hugolib: Adjust timeout for leaktest 2017-05-30 16:38:10 +03:00
Bjørn Erik Pedersen
ce624cc7d3 hugolib: Add slightly more realistic tag distribution to benchmark 2017-05-30 15:33:37 +03:00
Bjørn Erik Pedersen
8930e259d7 hugolib: Add site building benchmarks
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
2017-05-30 14:30:30 +03:00
Bjørn Erik Pedersen
19de4476d8 hubolib: Remove the regular page restriction from .Site.GetPage
See #2844
2017-05-26 21:31:45 +03:00
Bjørn Erik Pedersen
b5b41c4468 hugolib: Refine allKindsInPages 2017-05-26 10:51:17 +03:00
Bjørn Erik Pedersen
612f6e3afe hugolib: Fix ref/relref issue with duplicate base filenames
This commit also makes that function 80x faster.

Fixes #2507
2017-05-26 10:42:45 +03:00
Bjørn Erik Pedersen
50d11138f3 hugolib: Add a cache to GetPage
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%
```
2017-05-26 10:42:45 +03:00
Bjørn Erik Pedersen
e0c2e79820 hugolib: Support regular pages in .Site.GetPage
Fixes #2844
2017-05-26 10:42:45 +03:00
Bjørn Erik Pedersen
8b49c3a175 hugolib: Enable leaktest
See #3082
2017-05-23 20:40:20 +03:00
Bjørn Erik Pedersen
fbb78b89df hugolib: Speed up GetPage
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
2017-05-23 15:18:26 +03:00
Bjørn Erik Pedersen
6c560288a6 hugolib: Add BenchmarkGetPage 2017-05-23 12:10:15 +03:00
Bjørn Erik Pedersen
e682fcc622 hugolib: Fix RSSLink vs RSS Output Format
Fixes #3450
2017-05-17 22:14:31 +03:00
Bjørn Erik Pedersen
6e2f2dd8d3 hugolib: Fix output formats override when no outputs definition given
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
2017-05-17 19:00:15 +03:00
Bjørn Erik Pedersen
af72db806f hugolib: Handle shortcode per output format
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
2017-05-13 22:44:15 +03:00
Bjørn Erik Pedersen
e951d65771 hugolib: Handle any errors in processShortcodes 2017-05-13 22:44:15 +03:00
Bjørn Erik Pedersen
2bcbf10400 hugolib: Prepare render per output format
See #3220
2017-05-13 22:44:15 +03:00
Bjørn Erik Pedersen
1e4d082cf5 hubolib: Refactor site rendering with an "output format context"
Fixes #3397
2017-05-13 22:44:15 +03:00
Bjørn Erik Pedersen
544f0a6394 hugolib: The deprecated Extension, Now and TargetPath will now ERROR 2017-05-10 20:05:52 +02:00
Bjørn Erik Pedersen
5794a265b4 commands, hugolib: Deprecate disable404, disableRSS, disableSitemap, disableRobotsTXT
Use disableKinds instead.

Fixes #3345
2017-05-10 20:00:08 +02:00
Bjørn Erik Pedersen
ebf677a583 hubolib: Embed Page in WeightedPage
People can still say `.Page`, but by embedding it `WeightedPages` can be used interchangeably with `Pages` in templates.

Fixes #3435
2017-05-09 23:58:25 +02:00
Bjørn Erik Pedersen
58d9cbd31b hugolib: Improve shortcode error message 2017-05-09 18:43:48 +02:00
Chase Adams
42f4ce15a9 hugolib: Add default config for ignoreFiles 2017-05-06 09:41:24 +02:00
Bjørn Erik Pedersen
8a49c0b3b8 tpl/collections: Make it a package that stands on its own
See #3042
2017-05-01 15:13:41 +02:00
Cameron Moore
de7c32a1a8 tpl: Add template function namespaces
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
2017-04-30 10:56:38 +02:00
Mitchell Cohen
154e18ddb9 Render 404 in default language only
This prevents 404.html from being re-rendered for each site.

Fixes #3075
2017-04-30 10:40:37 +02:00
Bjørn Erik Pedersen
8d0917af0a hubolib: Narrow a test assertion 2017-04-27 13:00:24 +02:00