Skip to content

minifiers: Keep x-bind and blank namespace in SVG minification#14671

Merged
bep merged 1 commit intogohugoio:masterfrom
bep:fix/minify-14669
Mar 26, 2026
Merged

minifiers: Keep x-bind and blank namespace in SVG minification#14671
bep merged 1 commit intogohugoio:masterfrom
bep:fix/minify-14669

Conversation

@bep
Copy link
Copy Markdown
Member

@bep bep commented Mar 25, 2026

Update tdewolff/minify to v2.24.11 and add "" and "x-bind" to KeepNamespaces
to prevent Alpine.js directives from being stripped in SVGs.

This is a new option in tdewolff/minify v2.24.11, and it is needed to prevent breakage of Alpine.js, and possilby others, directives in SVGs.

Fixes #14669

Update tdewolff/minify to v2.24.11 and add "" and "x-bind" to KeepNamespaces
to prevent Alpine.js directives from being stripped in SVGs.

This is a new option in tdewolff/minify v2.24.11, and it is needed to prevent breakage of Alpine.js, and possilby others, directives in SVGs.

Fixes gohugoio#14669
@gemini-code-assist
Copy link
Copy Markdown

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Hugo’s minifier configuration and tests to accommodate new SVG namespace-keeping behavior in tdewolff/minify so Alpine.js-style SVG directives (e.g., x-bind:*) aren’t stripped during minification.

Changes:

  • Bump github.com/tdewolff/minify/v2 to v2.24.11 (and parse/v2 to v2.8.11).
  • Configure the default SVG minifier to keep namespaces "" and "x-bind".
  • Add regression tests for SVG minification preserving x-bind:* and :href attributes.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
minifiers/config.go Sets default svg.Minifier.KeepNamespaces to preserve Alpine/Vue-style directive attributes.
minifiers/minifiers_test.go Adds regression cases for Issue #14669 around SVG attribute preservation.
go.mod Updates tdewolff/minify and tdewolff/parse versions.
go.sum Records new module checksums for the dependency updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bep bep merged commit 42289d7 into gohugoio:master Mar 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG minifier broken for e.g. AlpineJS bindings

2 participants