Commit Graph

616 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 134674f00d Continue resolving on ERR_ACCESS_DENIED in Node's resolver
And then rethrow the ERR_ACCESS_DENIED if we cannot recover.

There's more details in #15041, but this error has been seen on Netlify with the CJS because of how Netlify has their node_modules cache folder set up.

Fixes #15041
2026-06-15 15:53:19 +02:00
Bjørn Erik Pedersen 781fabf4e4 all: Run go fix ./... 2026-06-07 21:20:40 +02:00
Bjørn Erik Pedersen cf18b827e2 images: Deprecate Imaging.Compression and move it down to webp and avif configs
Also clean up and simplify the image config handling.

Closes #14998
2026-06-07 21:20:16 +02:00
Bjørn Erik Pedersen 98ad9b3c03 Only support the latest Go version
Which is currently Go 1.26.

Closes #14997
2026-06-07 17:01:04 +02:00
Bjørn Erik Pedersen ff2903a931 resources/jsconfig: Remove deprecated baseUrl setting
baseUrl is deprecated in TypeScript and is no longer required when
paths is set (TypeScript 4.1+).

Fixes #14991
Closes #14996
2026-06-07 13:35:25 +02:00
Bjørn Erik Pedersen b89e7fe675 page: Add IsBranch and deprecate IsNode
IsNode's meaning was murky. Add IsBranch, defined as the set of branch
node kinds (home, section, taxonomy, term), and make IsNode a deprecated
alias for it.

Fixes #11574

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 16:18:57 +02:00
Bjørn Erik Pedersen e8fefc8388 images: Force cache invalidation for AVIF target
Fixes #14990
2026-06-05 16:18:23 +02:00
Bjørn Erik Pedersen a043d3ec63 images: Add a per-format AVIF hint setting
The hint setting controls WebP encoding (preset) and AVIF encoding
(chroma subsampling), but only lived on imaging.webp. Add imaging.avif.hint
so it shows up under the AVIF section in the docs, with the same root-level
backwards compatibility as imaging.webp.hint. Per-image hint now resolves
from the target format.

Fixes #14992

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 16:16:38 +02:00
Bjørn Erik Pedersen 341f575d2d images: Make AVIF chroma subsampling content-aware via the hint
Encode photo/picture hints (and the default) as YUV420 instead of YUV444,
keeping 444 for text/icon/drawing. Lossless stays 444.

This roughly halves the encoder's peak memory (42 -> 27 MiB/MP) and the
output size, while 444 remains available for sharp-edged content. A
3000x3000 image now needs ~239 MiB to encode, down from ~381 MiB (which
sat right at the 384 MiB WASM cap).

Closes #14987

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 18:54:56 +02:00
Bjørn Erik Pedersen 4e47d95db9 config: Deprecate the glogal imaging quality setting
In favour of the new per-image quality setting.

See #14979
2026-06-04 11:07:34 +02:00
Bjørn Erik Pedersen 03b4b54220 images: Make 60 the default quality for AVIF
AVIF's quality scale is not perceptually comparable to JPEG/WebP:
libavif anchors its "good" default at 60, where Hugo's universal 75
produced visibly higher quality and larger files. AVIF now defaults to
60 while JPEG and WebP keep 75. An explicit imaging.quality,
imaging.avif.quality or a per-image qNN still wins.

Fixes #14979

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 11:07:34 +02:00
Bjørn Erik Pedersen b01ecd4cd4 images: Add quality setting per image format
Allow setting quality per output format via imaging.jpeg.quality,
imaging.webp.quality and imaging.avif.quality. Each falls back to the
global imaging.quality when unset, and a per-image qNN still wins.

Fixes #14957

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 20:43:55 +02:00
Joe Mooring 45c00b7c16 misc: Remove duplicate words in comments
Closes #14936
Closes #14950
Closes #14965
2026-05-29 17:54:14 +02:00
Bjørn Erik Pedersen 28d882ab70 Add some PNG to AVIF golden test cases
Both 8 and 24 bit PNG to AVIF with vivid colors.

The output looks good to me ...

https://discourse.gohugo.io/t/v0-162-0-avif-image-processing-strips-washes-out-colors-on-vector-graphics/57210
2026-05-29 11:28:27 +02:00
Bjørn Erik Pedersen 90d9f812b2 Add image processing support for AVIF
The encode/decode is implemented in a WebAssembly module built from a
small C wrapper around libavif. Bundled libraries (statically linked,
compiled with the WASI SDK):

* libavif v1.4.1 (container + codec glue)
* libaom v3.14.1 (AV1 encoder + decoder)
* dav1d 1.5.3 (AV1 decoder)
* libyuv (Chromium pin) for color conversion
* parson for JSON message passing across the wasm boundary

HDR handling on the encoder:

* SDR images are written as BT.709 / sRGB / BT.601 (8-bit).
* 10-bit and up are written as BT.2020 primaries with PQ (SMPTE
  ST 2084) transfer and BT.2020-NCL matrix coefficients, signalled
  via CICP.
* Adobe-style SDR+gainmap inputs (e.g. Lightroom HDR exports) are
  baked into a single true-HDR image in BT.2020/PQ at 10-bit, with
  the CLLI (Content Light Level Information) box carried through so
  HDR-capable clients can tone-map correctly.

Limitations:

* Animated input (animated WebP/GIF) is collapsed to its first frame
  when re-encoded as AVIF; animated AVIF output is not yet supported.

Fixes #7837
2026-05-26 12:13:53 +02:00
Bjørn Erik Pedersen c4bbc2805c all: Replace RWMutex struct caches with ConcurrentMap 2026-05-24 15:29:47 +02:00
Joe Mooring 5d51b82a7e resources: Fix the :counter placeholder
Closes #14921

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 09:45:11 +02:00
Bjørn Erik Pedersen ae7bf74b3e common/hexec: Make NODE_PATH a fallback for ESM bare imports
Node's ESM resolver does not consult NODE_PATH (unlike CJS require), so
an ESM postcss.config.js shipped by a Hugo theme fails when loaded from
the module cache: bare imports like `import x from "postcss-import"`
have no node_modules to walk up to.

Install a synchronous resolver hook (module.registerHooks) via
--import=data:... on every Node invocation. On ERR_MODULE_NOT_FOUND for
a bare specifier it resolves the package from each NODE_PATH entry via
createRequire().resolve(). No-op for relative, absolute, URL-scheme and
non-MODULE_NOT_FOUND failures. Synchronous hooks run on the main thread,
so no --allow-worker is needed under the Node permission model.

Fixes #13987

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 22:00:04 +02:00
Alexandre Vaz f0cfc28c00 resources/images: Keep smart crop target size
Smartcrop can return a crop rectangle that is smaller than the requested dimensions after prescaling and rounding. Expand that rectangle within the source image bounds before applying Hugo's crop/fill pipeline, so smart crops keep the requested size without stretching the image.

Bump the smart crop cache version for crop/fill only.

Fixes #13688

Co-Authored-By: Joe Mooring <joe.mooring@veriphor.com>
2026-05-13 12:10:44 +02:00
Bjørn Erik Pedersen 86fbb0f7a8 security: Validate redirects against security.http.urls
A server allowed by security.http.urls could redirect resources.GetRemote
to a host that is not. Re-run the check on each hop via CheckRedirect.

Fixes #14871
2026-05-13 10:06:43 +02:00
Bjørn Erik Pedersen e51e761d9c css: Make css.Build's file-loader URLs absolute to web context root
When CSS imports assets via the file loader (fonts, images), the emitted
URLs were relative to the CSS output directory. That broke when the CSS
was inlined into HTML, since browsers then resolved the URLs against the
page rather than the CSS file.

Set esbuild's PublicPath to the CSS output directory joined with the
site base path so URLs work whether the CSS is published as a file or
inlined.

Fixes #14849
2026-05-10 19:08:08 +02:00
Bjørn Erik Pedersen c4eba92863 resources: Honor Retry-After header in resources.GetRemote retries
When the server returns a temporary HTTP error (e.g. 429 or 503)
together with a Retry-After header, use that value as the next sleep
duration instead of the default exponential backoff. The Retry-After
value is also surfaced in the retry-timeout error message.

Fixes #14828
2026-04-29 15:44:16 +02:00
Bjørn Erik Pedersen 7622dd86ce css: Support nested hugo:vars/<name> imports
Allow CSS variables to be grouped under sub-paths and imported via
@import "hugo:vars/mobile" (or @use for Dart Sass), so callers can pass
nested dicts like:

    {{ dict "primary-color" "blue" "mobile" (dict "primary-color" "red") }}

Top-level "hugo:vars" now skips nested map entries instead of emitting
garbage for them.

Fixes #14705

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 19:42:50 +02:00
Bjørn Erik Pedersen 90d8bf34ae Replace deprecated .Site.Sites/.Page.Sites with hugo.Sites intests 2026-04-24 19:02:46 +02:00
Bjørn Erik Pedersen a54c398b93 Harden Node tool execution with --permission flag
Add security.node.permissions config to run Node tools (PostCSS, Babel,
TailwindCSS) under Node's permission model, restricting file system access
to the working directory by default.

The binary resolution is simplified to node_modules/.bin → PATH (npx removed).
For both locations, the actual JS entry point is resolved via symlinks (macOS/Linux)
or by parsing npm wrapper scripts (Windows .cmd), then executed as
"node --permission --allow-fs-read=<path> --allow-fs-write=<path> <script>".

Users can opt out by removing "node" from security.exec.allow.

Closes #7287
2026-04-22 15:47:34 +02:00
Bjørn Erik Pedersen 7574e35b40 Replace the concurrent map with an identical upstream version 2026-04-20 18:33:59 +02:00
Bjørn Erik Pedersen 017a7cd63a Add slice-based permalinks config with PageMatcher target
Closes #14744
Clses #4641

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-19 19:45:45 +02:00
Joe Mooring 0d58e4286f resources/page: Add passing test for Issue #14325 2026-04-18 15:02:47 +02:00
Bjørn Erik Pedersen 9747724222 Fix it so we never auto-fallback to page resources in other roles/versions
This is some logic that's left behind from when we had only one dimension (language) where the common case would be to have one resource set (e.g. an image) and many content translation.

After this commit:

* For sites matrix defined in the content filename (e.g. data.en.js) or in its mount definition, we may use that as a fallback for e.g. German languages if we don't find a better match.
* For content adapters, this is not relevant: Here you must be explicit about this.
* We never auto-fallback on resources from a role/version to another.
* When a page bundle spans multiple roles (e.g. via roles = "*"), we clone its resources to all roles so each gets role-specific paths.

Fixes #14749
Fixes #14752
2026-04-14 16:33:38 +02:00
Bjørn Erik Pedersen 4e91e14cb0 Fix some recently introduced Position issues
Fixes #14710
2026-04-04 14:53:20 +02:00
Bjørn Erik Pedersen 481baa0896 all: Replace NewIntegrationTestBuilder with Test/TestE/TestRunning 2026-04-03 21:17:45 +02:00
Joe Mooring df520e3150 resources/page: Fix shared reader in Source.ValueAsOpenReadSeekCloser
Closes #14684

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 21:32:28 +01:00
Bjørn Erik Pedersen a8fca598e6 Replace deprecated site.Data with hugo.Data in tests
This also fixes a subtle server reload issue when changing files inside /data and using the recently added hugo.Data method.
2026-03-21 19:09:14 +01:00
Bjørn Erik Pedersen eb11c3d0bc Replace deprecated :filename with :contentbasename in the permalinks test 2026-03-18 08:47:26 +01:00
Bjørn Erik Pedersen 3c980c072e resources: Re-publish on transformation cache hit
When a resource transformation result was served from cache (same
options as a previous build), the output file was not re-written to
disk. This caused incorrect output when toggling transformation
options (e.g. minify) back to a previously seen value in server mode.

Fixes #14629
2026-03-15 18:32:41 +01:00
Bjørn Erik Pedersen e431f90bc6 tpl/css: Fix external source maps
Fixes #14620
2026-03-14 12:08:18 +01:00
Bjørn Erik Pedersen 3e3b849cc7 Add css.Build
Fixes #14609
Fixes #14613
2026-03-12 13:32:40 +01:00
Bjørn Erik Pedersen 842d8f1052 resources: Fix context canceled on GetRemote with per-request timeout
The per-request timeout context was cancelled via defer in the getRes
closure, before io.ReadAll(res.Body) in the outer scope could read
the response body. Fix this by returning the cancel function from
getRes so each caller manages its own cancel lifecycle.

Fixes #14611

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:45:14 +01:00
Bjørn Erik Pedersen c47ec23342 resources: Use full path for Exif etc. decoding error/warning messages
Fixes #12693
2026-03-08 23:03:57 +01:00
Bjørn Erik Pedersen e3108225bf all: Run go fix ./... 2026-03-07 18:30:42 +01:00
Joe Mooring d4f2122dea refactor: Deprecate language configuration and template methods
Configuration:

- languageCode      -> locale (either in root or per-language)
- languageName      -> label
- languageDirection -> direction

Methods:

- .Language.LanguageCode      -> .Language.Locale
- .Language.LanguageName      -> .Language.Label
- .Language.LanguageDirection -> .Language.Direction
- .Site.LanguageCode          -> .Site.Language.Locale

Example configuration:

[languages.en]
  direction = 'ltr'
  label     = 'English'
  locale    = 'en-US'
  weight    = 1

Closes #14269

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 11:45:52 +01:00
Bjørn Erik Pedersen 991d2f9aba Replace Exif with Meta in tests 2026-03-04 11:38:28 +01:00
Joe Mooring e8577771c3 resources: Improve getImageOps error message
Closes #14571
2026-02-26 22:20:08 +01:00
Bjørn Erik Pedersen 44dc3847f4 resources/images: Add IsImageResourceWithMeta etc. tests for bmp and gif
Closes #14568
2026-02-26 16:49:11 +01:00
Bjørn Erik Pedersen 8e28668b09 docs: Regen and fix the imaging docshelper output
Fixes #14562
2026-02-25 10:43:58 +01:00
Bjørn Erik Pedersen 49bfb1070b Add AVIF, HEIF and HEIC partial support (only metadata for now)
* Add AVIF, HEIF and HEIC partial support

* Add them as media types.
* Support reading metadata (Width, Height, Exif, etc.) from these formats.
* Add a new template function IsImageResourceMeta to check if a resource supports image metadata operations, which will return true for AVIF, HEIF and HEIC resources even if they don't support full image operations yet.

Fixes #14549
2026-02-24 19:45:12 +01:00
Joe Mooring b7203bbb3a resources/images: Adjust WebP processing defaults
defaultWebpUseSharpYuv: true => false
defaultWebpMethod: 4 => 2
2026-02-24 10:02:48 +01:00
Paul van Brouwershaven 2d691c7e47 Add per-request timeout option to resources.GetRemote 2026-02-23 16:38:13 +01:00
Bjørn Erik Pedersen 86aa62524f hugolib: Move site.Data to hugo.Data, deprecate Site.AllPages/BuildDrafts/Languages
This moves Site.Data to the hugo namespace as hugo.Data, following the
same pattern used for hugo.Sites. Also deprecate Site.AllPages,
Site.BuildDrafts, and Site.Languages.

Closes #14521

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 14:34:47 +01:00
Bjørn Erik Pedersen 29b8e17d29 hugolib: Adjust hugo.Sites.Default
Fixes #14531
2026-02-17 19:10:47 +01:00