Adding a Structured Block
Adding A Shortcode Or Structured Block
Use this recipe when adding a new authored block to the generator.
Choose The Authoring Shape
- Use a shortcode when the syntax is naturally inline or shortcode-like.
- Use a fenced codeblock when authors need YAML/JSON-style structured data.
- Support both only when there is a real migration or ergonomics reason.
Hugo remains the render authority. Browser code may hydrate or edit the rendered object, but should not become a second renderer.
Implementation Checklist
- Add the Hugo render path:
- shortcode:
layouts/shortcodes/<name>.html; - fenced block:
layouts/_default/_markup/render-codeblock-<name>.html; - shared renderer if needed:
layouts/partials/etc/*,layouts/partials/widgets/*, or feature-specific partials.
- shortcode:
- Add TeX output only if the block should work in TeX/PDF output:
layouts/shortcodes/<name>.tex;layouts/_default/_markup/render-codeblock-<name>.tex.
- Add browser runtime only if the rendered DOM needs hydration:
cdn/custom/<name>.js;- register through the shared runtime/widget path;
- handle SPA reinitialization.
- Add styles through the shared token/scoped-surface model, not site-local forks.
- Update docs:
docs/shortcodes.mdfor authoring syntax;- relevant Hugo/JavaScript docs if the block adds a new integration pattern.
- Update machine-readable inventories where applicable:
docs/shortcodes.manifest.json;docs/structured-blocks.manifest.json;docs/editor-surface.manifest.json;cdn/custom/structured-block-editor-contract.jsor its generator scripts when the block is structured-editable.
- Test at the narrowest useful level:
- Hugo build/render check against a fixture page;
- JS syntax check for new runtime files;
- browser smoke if the block has SPA/runtime behavior.
Common Boundaries
- Do not reimplement Hugo render hooks in JavaScript.
- Do not write HTML as source when Markdown/config can remain source.
- Keep widget internals scoped to their own token aliases.
- Keep source docs and manifests synchronized with the new authoring contract.
Files To Read
docs/shortcodes.mddocs/hugo-render-hooks.mddocs/widget-integration-plan.mddocs/structured-blocks.manifest.jsondocs/editor-surface.manifest.json