212 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen
b9b304a126 testing: Port integration tests to new templates structure
As introduced in  v0.146.0. Keep some legecy test to preserve backwards compatibility.
2025-11-27 12:00:15 +01:00
Joe Mooring
565a10cbf0 config/privacy: Change GoogleAnalytics.RespectDoNotTrack default to true
Closes #13307
2025-11-27 09:46:53 +01:00
Joe Mooring
3d21b0687b markup/asciidocext: Improve Asciidoctor integration
Fixes an issue where improper attribute derivation from the page's
relative permalink caused failures with `outdir`, `imagesoutdir`, and
`imagesdir` when `markup.asciidocext.workingFolderCurrent` is enabled.
The updated logic now correctly handles:

- Multi-byte characters
- Multilingual multi-host sites
- Site builds from a subdirectory
- Pages using ugly URLs

Supports diagram caching as implemented in v3.1.0 of the asciidoctor-diagram
extension:

- Enables caching by default
- Sets default cache location to the compiled value of caches.misc.dir

Reduces duration of integration tests by:

- Generating GoAT diagrams instead of Ditaa diagrams
- Taking advantage of asciidoctor-diagram caching

Closes #9202
Closes #10183
Closes #10473
Closes #14160
2025-11-24 23:03:53 +01:00
Bjørn Erik Pedersen
ca4025405c Optimize memory allocations for sites matrix vector stores
By

* Caching common sites matrix setups (e.g. the single site in single site setups).
* Adding a fast path to IntSets.HasAnyVector for the common case of single vector input.

```
AssembleDeepSiteWithManySections/depth=3/sectionsPerLevel=2/pagesPerSection=100-10   31.62m ± 46%   30.68m ± 42%  ~ (p=0.310 n=6)

                                                                                   │ master.bench │          perfcommon.bench          │
                                                                                   │     B/op     │     B/op      vs base              │
AssembleDeepSiteWithManySections/depth=3/sectionsPerLevel=2/pagesPerSection=100-10   31.98Mi ± 0%   31.24Mi ± 0%  -2.30% (p=0.002 n=6)

                                                                                   │ master.bench │         perfcommon.bench          │
                                                                                   │  allocs/op   │  allocs/op   vs base              │
AssembleDeepSiteWithManySections/depth=3/sectionsPerLevel=2/pagesPerSection=100-10    460.9k ± 0%   419.9k ± 0%  -8.90% (p=0.002 n=6)
````
2025-11-17 16:01:37 +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
Joe Mooring
e1236e3d0d config: Add struct tags to deprecated and unused fields
This will remove these fields from the output of newDocsHelper.
2025-11-09 12:59:46 +01:00
Bjørn Erik Pedersen
04650ce778 all: Run modernize -fix ./...
Closes #14107
2025-11-05 21:05:42 +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
Bjørn Erik Pedersen
0579afc3c5 Fix "assignment to entry in nil map" on empty YAML config files
Fixes #14074
2025-10-22 13:40:03 +02:00
Bjørn Erik Pedersen
a1307700dd config: Clone language map entries before modifying them
Now, with YAML anchor and alias support, these can point to shared data,
which must not be modified in place.

Fixes #14072
2025-10-21 13:34:15 +02:00
Bjørn Erik Pedersen
bd50c9c7e7 Misc YAML adjustments
Closes #14067
2025-10-20 16:05:05 +02:00
Joe Mooring
3b8947d821 config/security: Add PROGRAMDATA to the osenv allowlist 2025-09-06 18:11:38 +02:00
PikachuTW
e751afa9bd Fix config env handling for some slice options
Fixes #13950
2025-09-04 10:49:14 +02:00
Joe Mooring
a09b8a60eb minifiers: Update deprecation handling
1. With minify.tdewolff.css and minify.tdewolff.svg, check
   for "decimals" instead of "decimal"

2. Add deprecation messages for:

  - minify.tdewolff.css.decimals
  - minify.tdewolff.svg.decimals
  - minify.tdewolff.html.keepconditionalcomments
  - config root minify (bool)
  - config root minifyoutput (bool)

3. Deprecate minify.tdewolff.css.keepcss2 in favor
   of minify.tdewolff.css.version

4. Refactor minify configuration tests

Closes #11893
Closes #13947
Closes #13948
2025-09-03 10:56:32 +02:00
Ruslan Semagin
266d46dccc config: Increase test coverage 2025-07-07 11:27:34 +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
Bjørn Erik Pedersen
eaf5ace30d Fix recent regression with cascading of params to content adapters
Fixes #13743
2025-05-26 21:26:19 +02:00
Bjørn Erik Pedersen
bc98e7a80d config: Fix env override of slices
Fixes #13707
2025-05-11 19:24:24 +02:00
Bjørn Erik Pedersen
c745a3e108 Fix/implement cascade for content adapters
Fixes #13692
2025-05-10 15:12:24 +02:00
Bjørn Erik Pedersen
b39b249623 config: Add some more merge tests
See #13681
2025-05-02 11:15:38 +02:00
Bjørn Erik Pedersen
179aea11ac config: Fix _merge issue when key doesn't exist on the left side
Fixes #13643
Fixes #13646
2025-04-24 13:56:27 +02:00
Christian Oliff
6a0e04241a all: Fix typos 2025-04-24 10:19:17 +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
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
Bjørn Erik Pedersen
812ea0b325 config: Use the non-global logger for deprecations when possible
To prevent warnings leaking into parallel tests.
2025-04-03 13:43:54 +02:00
Bjørn Erik Pedersen
521911a576 all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
Joe Mooring
5de3913ed4 config/allconfig: Deprecate :filename and :slugorfilename tokens 2025-02-17 12:06:32 +01:00
Peter Weston
c1f4228d61 config: Fix server.redirects.fromRe being ignored unless server.redirects.from is also set 2025-02-14 10:21:19 +01:00
Joe Mooring
34dcac53bf config: Remove unused code 2025-02-13 08:40:49 +01:00
Bjørn Erik Pedersen
9b5f786df8 Deprecate kind, lang, and path from front matter
These were added to the page meta object when we implemented "pages from data", but were not meant to be used in front matter.

That is not supported, so we might as well add validation.

Fixes #12484
2025-02-10 21:22:43 +01:00
Bjørn Erik Pedersen
c2fb221209 Add ContentTypes to config
This is an empty struct for now, but we will most likely expand on that.

```
[contentTypes]
  [contentTypes.'text/markdown']
```

The above means that only Markdown will be considered a content type. E.g. HTML will be treated as plain text.

Fixes #12274
2025-02-08 10:31:15 +01:00
Bjørn Erik Pedersen
029d1e0ced Add some more server options/improvements
New options:

* `FromHeaders`: Server header matching for redirects
* `FromRe`: Regexp with group support, i.e. it replaces $1, $2 in To with the group matches.

Note that if both `From` and `FromRe` is set, both must match.

Also

* Allow redirects to non HTML URLs as long as the Sec-Fetch-Mode is set to navigate on the request.
* Detect and stop redirect loops.

This was all done while testing out InertiaJS with Hugo. So, after this commit, this setup will support the main parts of the protocol that Inertia uses:

```toml
[server]
    [[server.headers]]
        for = '/**/inertia.json'
        [server.headers.values]
            Content-Type = 'text/html'
            X-Inertia    = 'true'
            Vary         = 'Accept'

    [[server.redirects]]
        force       = true
        from        = '/**/'
        fromRe      = "^/(.*)/$"
        fromHeaders = { "X-Inertia" = "true" }
        status      = 301
        to          = '/$1/inertia.json'
```

Unfortunately, a provider like Netlify does not support redirects matching by request headers. It should be possible with some edge function, but then again, I'm not sure that InertiaJS is a very good fit with the common Hugo use cases.

But this commit should be generally useful.
2025-02-05 18:14:15 +01:00
Bjørn Erik Pedersen
7f0f50b133 Make cascade front matter order deterministic
Fixes #12594
2025-01-23 09:45:47 +01:00
Bjørn Erik Pedersen
1f5a15aba0 resources: Fix 2 image file cache key issues
* Always include the content hash in the cache key for unprocessed images.
* Always include the image config hash in the cache key.

This is also a major cleanup/simplification of the implementation in this area.

Note that this, unfortunately, forces new hashes/filenames for generated images.

Fixes #13273
Fixes #13272
2025-01-18 12:23:18 +01:00
Joe Mooring
1191467c05 tpl/tplimpl: Deprecate twitter shortcode in favor of x shortcode
Closes #13214
2025-01-16 10:33:34 +01:00
Bjørn Erik Pedersen
76993369a0 For render hooks, only fallback to HTML (or the defaultOutputFormat) template
Closes #13242
2025-01-15 19:59:58 +02:00
Bjørn Erik Pedersen
cfa0801815 Fix NPX issue with TailwindCSS v4
This allows the `tailwindcss` CLI binary to live in the `PATH` for NPM-less projects.

Fixes #13221
2025-01-07 13:12:08 +01:00
Joe Mooring
7888ac585c config/allconfig: Fix slice of language configs
Fixes #13201
2024-12-30 10:54:56 +01:00
Joe Mooring
eb1dbe0709 config/allconfig: Throw error when output format is not defined
Fixes #13199
2024-12-29 21:38:46 +01:00
Bjørn Erik Pedersen
75ad9cdaab Add config option disableDefaultLanguageRedirect
Fixes #13133
2024-12-12 21:47:03 +01:00
Bjørn Erik Pedersen
e293e7ca6d Add js.Batch
Fixes #12626
Closes #7499
Closes #9978
Closes #12879
Closes #13113
Fixes #13116
2024-12-12 21:43:17 +01:00
Bjørn Erik Pedersen
ad43d137d5 Remove deprecations <= v0.122.0 (note)
These have, once we release this, been logging ERROR for 6 minor versions.
2024-11-16 20:32:43 +01:00
Bjørn Erik Pedersen
21366e0411 config: Imrove uglyurls section test
Updates #12926
2024-10-14 10:03:44 +02:00
Akkuman
ea633dd809 config: Fix uglyurls map parse
Fixes #12926
2024-10-14 10:03:44 +02:00
Joe Mooring
d1ba52f3c3 tests: Address deprecation warnings and errors 2024-09-29 10:49:26 +02:00
Bjørn Erik Pedersen
e363964f2f commands: Ignore "module does not exist" errors in hugo mod init
Closes #11458
2024-09-19 12:26:04 +02:00
Joe Mooring
7792392a6f config: Fix pagination deprecation messages 2024-08-21 22:01:59 +02:00
Bjørn Erik Pedersen
01008ba512 Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder
See #12776
2024-08-17 16:47:50 +02:00
Bjørn Erik Pedersen
e67886c038 Consolidate all hashing to the common/hashing package
And remove now unsued hashing funcs.
2024-07-31 16:44:06 +02:00
Bjørn Erik Pedersen
2babd6404e identity: Use xxHash in hashstructure (note)
```
name                 old time/op    new time/op    delta
HashString/n28-10       133ns ± 9%     107ns ±10%  -19.58%  (p=0.029 n=4+4)
HashString/n112-10      243ns ± 5%     121ns ± 4%  -50.08%  (p=0.029 n=4+4)
HashString/n448-10      698ns ± 3%     174ns ± 5%  -75.02%  (p=0.029 n=4+4)
HashString/n1792-10    2.58µs ± 4%    0.38µs ± 4%  -85.11%  (p=0.029 n=4+4)
HashString/n7168-10    10.0µs ± 3%     1.3µs ± 4%  -86.91%  (p=0.029 n=4+4)

name                 old alloc/op   new alloc/op   delta
HashString/n28-10       80.0B ± 0%     72.0B ± 0%  -10.00%  (p=0.029 n=4+4)
HashString/n112-10       160B ± 0%      152B ± 0%   -5.00%  (p=0.029 n=4+4)
HashString/n448-10       496B ± 0%      488B ± 0%   -1.61%  (p=0.029 n=4+4)
HashString/n1792-10    1.84kB ± 0%    1.83kB ± 0%   -0.43%  (p=0.029 n=4+4)
HashString/n7168-10    8.24kB ± 0%    8.23kB ± 0%   -0.06%  (p=0.029 n=4+4)

name                 old allocs/op  new allocs/op  delta
HashString/n28-10        4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.029 n=4+4)
HashString/n112-10       4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.029 n=4+4)
HashString/n448-10       4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.029 n=4+4)
HashString/n1792-10      4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.029 n=4+4)
HashString/n7168-10      4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.029 n=4+4)
```
2024-07-31 16:44:06 +02:00