Skip to content

command: hugo gen jsonschemas#13805

Open
bmackinney wants to merge 4 commits into
gohugoio:masterfrom
bmackinney:genJSONSchema
Open

command: hugo gen jsonschemas#13805
bmackinney wants to merge 4 commits into
gohugoio:masterfrom
bmackinney:genJSONSchema

Conversation

@bmackinney

@bmackinney bmackinney commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Reflects Hugo config and page frontmatter structs into json schemas.
Fixes #10984

AI Assistance Notice: This PR was written with substantial assistance from GitHub Copilot and OpenCode (Big Pickle model). The contributor is not a Go developer and relied on AI assistance for implementation.

@bmackinney bmackinney force-pushed the genJSONSchema branch 2 times, most recently from bdc3d74 to cd719ab Compare March 5, 2026 23:09
@bmackinney

Copy link
Copy Markdown
Contributor Author

@bep this is ready for you to review.

@bep

bep commented Mar 6, 2026

Copy link
Copy Markdown
Member

@bmackinney thanks for this. We have been doing a fair bit of work lately to get rid of/clean up some legacy APIs -- so this has not been a priority. After the next minor Hugo version I think we're more or less in a "stable API" situation, and I will have a closer look at this. And yes, I do agree that, especially for config, the VS code situation is less than optimal.

@bep bep self-assigned this Mar 21, 2026
@bep bep added this to the v0.159.0 milestone Mar 21, 2026
@bep

bep commented Mar 21, 2026

Copy link
Copy Markdown
Member

I will test this myself, but one quick question: The lower casing of the first char in Page methods/properties, is that correct (or: does that work?).

@bmackinney

Copy link
Copy Markdown
Contributor Author

It works and is correct for json schemas, but I'm going to improve the camel function to handle acronyms better (ID → id instead of iD, JS → js instead of jS).

bep added a commit to bep/hugoDocs that referenced this pull request Mar 23, 2026
From gohugoio/hugo#13805

To have public URL to test out these with.
@bep

bep commented Mar 23, 2026

Copy link
Copy Markdown
Member

@bmackinney I have tried to test this in a Netlify docs branch, but I have 2 issues:

  • It would be good for testing if either the $ref URLs were relative (not sure if that's possible) or if I could somehow set --baseURL when running the hugo getn jsonschemas. For testing I have done a "search and replace", which I guess works, but that's a little ... cumbersome.
  • But after doing that, I get "Error when resolving ...." e.g. hugo-config-params.schema.json. It's referenced, but the JSON file is not generated.

@bmackinney

Copy link
Copy Markdown
Contributor Author

@bep it's ready to re-test.

@bep bep modified the milestones: v0.159.0, v0.160.0 Mar 24, 2026
@bep

bep commented Mar 31, 2026

Copy link
Copy Markdown
Member

@jmooring I will do a more thorough test/review of this setup., but I would appreciated your input on structure/naming. I'm pretty convinced that this is worth adding, especially considering the poor state of the existing "Hugo schemas" out there.

The structure of this PR is currently:

  • config
    • markup
    • ... other config sections
  • page (which is page front matter)

I would think that we at least would want to have an option in the future to add JSON schemas for Hugo's template APIs, e.g. page (which conflicts with the above), site, hugo.

I'm not an JSON schema expert, but I suspect that it would be great if the structure somehow followed the documentation about the same topics.

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.

Add a JSON config schema

2 participants