Skip to content

resources/page: Add JSON omitzero tag to PageMatcher.Sites#14875

Closed
algojogacor wants to merge 1 commit into
gohugoio:masterfrom
algojogacor:master
Closed

resources/page: Add JSON omitzero tag to PageMatcher.Sites#14875
algojogacor wants to merge 1 commit into
gohugoio:masterfrom
algojogacor:master

Conversation

@algojogacor
Copy link
Copy Markdown

Summary

Fixes #14855

Running hugo config with legacy [permalinks] configuration prints empty sites sub-maps because PageMatcher.Sites has no JSON struct tag.

Root Cause

In resources/page/page_matcher.go:54, the Sites sitesmatrix.Sites field has no JSON struct tag. When the field is zero-valued during config output, json.Marshal emits {"matrix":{},"complements":{}}, and the downstream zero-value cleanup pass never calls IsZero() or removes these empty sub-maps.

Fix

Add json:"sites,omitzero" to line 54. Go 1.24+ omitzero calls the IsZero() method during marshal, dropping the field entirely when empty. This matches how the same sitesmatrix.Sites type is already tagged in commands/config.go.

Changes

  • resources/page/page_matcher.go: 1 line changed (+1 -1)

Testing

  • hugo config with legacy [permalinks] config: No empty sites sub-maps in output ✅
  • hugo config without permalinks: No regression ✅
  • Existing cascade/PageMatcher behavior: Unaffected (only affects JSON marshaling output) ✅

Running 'hugo config' with legacy [permalinks] config prints empty
sites sub-maps because Sites has no JSON struct tag. When the field is
zero-valued, json.Marshal emits {matrix:{},complements:{}} which
survives the zero-value cleanup pass.

Adding  ensures the field is omitted when its
IsZero() method returns true, matching how the same type is tagged
in commands/config.go.

Fixes #14855
@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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 counterproductive. 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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 12, 2026

CLA assistant check
All committers have signed the CLA.

@bep
Copy link
Copy Markdown
Member

bep commented May 12, 2026

Thanks; I think I prefer #14861 -- as that one works for all maps recursively and it also respects hugo config --printZero

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.

In "hugo config", don't print empty sub maps

3 participants