Bjørn Erik Pedersen
d83ce27ae0
tpl/tplimpl: Support sub paths in layouts passed to .Render
...
E.g. {{ .Render "foo/mylayout" }} matches mylayout templates in
<dir>/foo for every dir from the page's layout path up to the layouts root.
Closes #15056
Co-authored-by: Joe Mooring <joe.mooring@veriphor.com >
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-05 20:14:32 +02:00
Joe Mooring
e46d37a984
tpl/tplimpl: Make template name lookup case-insensitive
...
Closes #15057
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-06-28 15:36:29 +02:00
Bjørn Erik Pedersen
c48551677c
Fix panic on edit of legacy mapped template names that's also a valid path in the new setup
...
This mapping was added in Hugo `v0.146.0`.
Fixes #14740
2026-04-08 13:19:45 +02:00
Bjørn Erik Pedersen
4eafd9eb7b
tpl/tplimpl: Prefer early suffixes when media type matches
...
Fixes #13877
Close #14601
Co-Authored-By: Joe Mooring <joe.mooring@veriphor.com >
2026-03-08 21:42:36 +01:00
Bjørn Erik Pedersen
2e5132d8d2
tpl/collections: Add some more benchmarks for where and sort
2026-02-13 10:34:39 +01:00
Bjørn Erik Pedersen
608ed09a0a
Rename common/maps to common/hmaps ( #14384 )
...
Go's stdlid now has a maps package, which is very useful. We have been using imports on the form `xmaps "maps"`, but auto import tools doesn't handle this, which is annoying.
I have been thinking about this for some time, but have been holding back because of all the import changes. However, now is a good time to do this, with very little unmerged code.
2026-01-16 11:47:46 +01:00
Bjørn Erik Pedersen
7c19c196c3
Allow partials to work as decorators
...
Fixes #13193
2025-12-30 15:58:55 +01:00
Bjørn Erik Pedersen
0637adb239
Improve error messages for template failures
2025-12-17 21:12:15 +01:00
Bjørn Erik Pedersen
555dfa207a
Speedup and simplify page assembly for deeper content trees
...
This commit moves to a forked version go-radix (fork source has not had any updates in 3 years.), whith 2 notable changes:
* It's generic (using Go generics) and thus removes a lot of type conversions/assertions.
* It allows nodes to be replaced during walk, which allows to partition the tree for parallel processing without worrying about locking.
For this repo, this means:
* The assembly step now processes nested sections in parallel, which gives a speedup for deep content trees with a slight allocation penalty (see benchmarks below).
* Nodes that needs to be reinserted are inserted directly.
* Also, there are some drive-by fixes of some allocation issues, e.g. avoid wrapping mutexes in returned anonomous functions, a common source of hidden allocations.
```
│ master.bench │ perf-p3.bench │
│ sec/op │ sec/op vs base │
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=1/pagesPerSection=50-10 6.958m ± 3% 7.015m ± 3% ~ (p=0.589 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=100-10 14.25m ± 1% 14.56m ± 8% ~ (p=0.394 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=500-10 48.07m ± 3% 49.23m ± 3% ~ (p=0.394 n=6)
AssembleDeepSiteWithManySections/depth=2/sectionsPerLevel=6/pagesPerSection=100-10 66.66m ± 4% 66.47m ± 6% ~ (p=0.485 n=6)
AssembleDeepSiteWithManySections/depth=4/sectionsPerLevel=2/pagesPerSection=100-10 59.57m ± 4% 50.73m ± 5% -14.85% (p=0.002 n=6)
geomean 28.54m 27.92m -2.18%
│ master.bench │ perf-p3.bench │
│ B/op │ B/op vs base │
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=1/pagesPerSection=50-10 4.513Mi ± 0% 4.527Mi ± 0% +0.33% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=100-10 15.35Mi ± 0% 15.49Mi ± 0% +0.94% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=500-10 62.50Mi ± 0% 63.19Mi ± 0% +1.10% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=2/sectionsPerLevel=6/pagesPerSection=100-10 86.78Mi ± 0% 87.73Mi ± 0% +1.09% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=4/sectionsPerLevel=2/pagesPerSection=100-10 62.96Mi ± 0% 63.66Mi ± 0% +1.12% (p=0.002 n=6)
geomean 29.84Mi 30.11Mi +0.92%
│ master.bench │ perf-p3.bench │
│ allocs/op │ allocs/op vs base │
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=1/pagesPerSection=50-10 60.44k ± 0% 60.97k ± 0% +0.87% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=100-10 205.8k ± 0% 211.4k ± 0% +2.70% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=1/sectionsPerLevel=6/pagesPerSection=500-10 831.1k ± 0% 858.3k ± 0% +3.27% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=2/sectionsPerLevel=6/pagesPerSection=100-10 1.157M ± 0% 1.197M ± 0% +3.41% (p=0.002 n=6)
AssembleDeepSiteWithManySections/depth=4/sectionsPerLevel=2/pagesPerSection=100-10 839.9k ± 0% 867.8k ± 0% +3.31% (p=0.002 n=6)
geomean 398.5k 409.3k +2.71%
```
2025-11-25 11:37:05 +01:00
Bjørn Erik Pedersen
a2469d504e
testing: Rewrite all the old style integration tests to txtar style tests
...
And remove some not worth keeping (or too much work to convert).
2025-11-10 12:00:58 +01:00
Bjørn Erik Pedersen
264022a75a
Add roles and versions as new dimensions (in addition to language)
...
See the main issue #13776 for details.
Fixes #519
Fixes #13680
Fixes #13663
Fixes #13776
Fixes #13855
Fixes #13648
Fixes #13996
Fixes #14001
Fixes #14031
Fixes #13818
Fixes #13196
2025-11-05 20:39:25 +01:00
n1xx1
2216028620
Add a key to the partialCached deadlock prevention
...
Fixes #13889
2025-08-07 11:17:14 +02:00
Bjørn Erik Pedersen
9c57af1351
Fix regression with hyphenated codeblock templates, e.g. render-codeblock-go-html-template.html
...
Fixes #13864
Co-authored-by: Joe Mooring <joe.mooring@veriphor.com >
2025-07-27 14:39:39 +02:00
Joe Mooring
84b31721bf
markup/goldmark: Change link and image render hook enablement to enums
...
Closes #13535
2025-07-07 11:19:34 +02:00
Joe Mooring
18a9ca7d7a
tpl/tplimpl: Copy embedded HTML table render hook to each output format
...
Closes #13351
2025-06-21 14:37:47 +02:00
Bjørn Erik Pedersen
0c7b1a3f26
Fix live reload when editing inline partials
...
Fixes #13723
2025-05-22 13:15:41 +02:00
Bjørn Erik Pedersen
61317821e4
tpl: Narrow down the usage of plain text shortcodes when rendering HTML
...
After this commit, if you want to resolve `layouts/_shortcodes/myshortcode.txt` when rendering HTML content, you need to use the `{{%` shortcode delimiter:
```
{{% myshortcode %}}
```
This should be what people would do anyway, but we have also as part of this improved the error message to inform about what needs to be done.
Note that this is not relevant for partials.
Fixes #13698
2025-05-18 12:48:24 +02:00
Bjørn Erik Pedersen
6142bc701c
tpl: Fix theme overrides when theme has old layout setup (e.g. _default)
...
Fixes #13715
2025-05-18 12:48:24 +02:00
Bjørn Erik Pedersen
80f0595311
tpl: Fix case issue in templates.Exists
...
Fixes #13684
2025-05-05 11:23:52 +02:00
Bjørn Erik Pedersen
be93d5218b
tpl: Fix overlapping layout sections
...
Fixes #13672
2025-04-30 21:04:03 +02:00
Bjørn Erik Pedersen
ad4f63c92f
tpl: Remove some unreached code branches
2025-04-24 14:27:59 +02:00
Bjørn Erik Pedersen
496730840e
Revert the breaking change from 0.146.0 with dots in content filenames
...
Closes #13632
2025-04-22 19:23:19 +02:00
Bjørn Erik Pedersen
6d69dc88a4
tpl: Fix indeterminate template lookup with templates with and without lang
...
Close #13636
2025-04-22 17:29:39 +02:00
Bjørn Erik Pedersen
1408c156d8
tpl: Detect and fail on infinite template recursion
...
Fixes #13627
2025-04-21 15:17:20 +02:00
Bjørn Erik Pedersen
d61b9fc605
tpl: Fix language handling in partials
...
We now use the same code path for all templates re this.
Fixes #13612
2025-04-15 11:25:54 +02:00
Bjørn Erik Pedersen
65c94c7b23
tpl: Fix issue with partials without suffix
...
Fixes #13601
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
cf9e6904cc
tpl: Fix the case for a shortcode in a nested folder only
...
Fixes #13605
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
8a2830f2dc
tpl: Add proper file context to template parse errors
...
Fixes #13604
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
1e0287f472
tpl: Make {{ template "partials/foo.html" . }} work in older setups
...
Fixes #13599
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
30b9c19c76
tpl: Make any layout set in front matter higher priority
...
Fixes #13541
2025-04-12 18:12:06 +02:00
Bjørn Erik Pedersen
c8710625b7
tpl: Fix it so embedded render-codeblock-goat is used even if custom render-codeblock exists
...
Fixes #13595
2025-04-12 13:03:45 +02:00
Bjørn Erik Pedersen
d1c394442b
tpl: Fix codeblock hook resolve issue
...
Fixes #13593
2025-04-11 18:59:42 +02:00
Bjørn Erik Pedersen
1074e01152
tpl: Fix legacy section mappings
...
Fixes #13584
2025-04-11 18:23:51 +02:00
Bjørn Erik Pedersen
9221cbca49
tpl: Fix some baseof lookup issues
...
We were mistakingly using the templates (e.g. list.html) descriptor to resolve the base template and not the page,
which worked fine in most cases, but not all.
Fixes #13583
2025-04-11 18:23:51 +02:00
Bjørn Erik Pedersen
3b9f2a7ded
tpl: Skip dot and temp files inside /layouts
...
Fixes #13579
2025-04-10 18:41:01 +02:00
Bjørn Erik Pedersen
383dd82f95
tpl: Warn and skip non-hook templates inside /layouts/_markup
...
Fixes #13577
2025-04-10 16:54:05 +02:00
Bjørn Erik Pedersen
208a0de6c3
tpl: Add a partial lookup cache
...
````
│ stash.bench │ perf-v146.bench │
│ sec/op │ sec/op vs base │
LookupPartial-10 248.00n ± 0% 14.75n ± 2% -94.05% (p=0.002 n=6)
│ stash.bench │ perf-v146.bench │
│ B/op │ B/op vs base │
LookupPartial-10 48.00 ± 0% 0.00 ± 0% -100.00% (p=0.002 n=6)
│ stash.bench │ perf-v146.bench │
│ allocs/op │ allocs/op vs base │
LookupPartial-10 3.000 ± 0% 0.000 ± 0% -100.00% (p=0.002 n=6)
```
THe speedup above assumes reuse of the same partials over and over again, which I think is not uncommon.
This commits also adds some more lookup benchmarks. The current output of these on my MacBook looks decent:
```
BenchmarkLookupPagesLayout/Single_root-10 3031562 395.5 ns/op 0 B/op 0 allocs/op
BenchmarkLookupPagesLayout/Single_sub_folder-10 2515915 480.9 ns/op 0 B/op 0 allocs/op
BenchmarkLookupPartial-10 84808112 14.13 ns/op 0 B/op 0 allocs/op
BenchmarkLookupShortcode/toplevelpage-10 8111779 148.2 ns/op 0 B/op 0 allocs/op
BenchmarkLookupShortcode/nestedpage-10 8088183 148.6 ns/op 0 B/op 0 allocs/op
```
Note that in the above the partial lookups are cahced, the others not (they are harder to cache because of the page path).
Closes #13571
2025-04-10 11:07:19 +02:00
Bjørn Erik Pedersen
d4c6dd16b1
tpl: Add templates.Current
...
This commit also
* Unexport all internal state in TemplateInfo.
* Make the dispatcher keys used for passing context.Context into uint8 from string to save memory allocations.
Co-authored-by: Joe Mooring <joe@mooring.com >
Updates #13571
2025-04-09 20:15:40 +02:00
Bjørn Erik Pedersen
83cfdd78ca
Reimplement and simplify Hugo's template system
...
See #13541 for details.
Fixes #13545
Fixes #13515
Closes #7964
Closes #13365
Closes #12988
Closes #4891
2025-04-06 20:59:41 +02:00