Skip to content

A start towards partial decorators for better composability#692

Draft
agriyakhetarpal wants to merge 5 commits intoscientific-python:mainfrom
agriyakhetarpal:partial-decorators
Draft

A start towards partial decorators for better composability#692
agriyakhetarpal wants to merge 5 commits intoscientific-python:mainfrom
agriyakhetarpal:partial-decorators

Conversation

@agriyakhetarpal
Copy link
Member

@agriyakhetarpal agriyakhetarpal commented Dec 31, 2025

This PR introduces the use of partial decorators, a new feature in Hugo released with v0.154.0: https://github.com/gohugoio/hugo/releases/tag/v0.154.0. This will not be a user-facing change for our users. The documentation is at https://gohugo.io/functions/templates/inner/ and is currently a bit sparse, but still understandable. From the docs: I have bumped to Hugo v0.154.5 with this PR.

A partial decorator is a partial template called from any other template including shortcodes, render hooks, and other partials.

There are some more examples here: gohugoio/hugoDocs#3330. I was able to do this for a couple of partials in this PR. Particularly, we can start using this for the list partial (with and without summary) and for the content container (breadcrumbs and title/subtitle) that occupies space on all pages.

I also tried to add something to deduplicate the grid of items and cards, but that turned out to be more complicated – the content inside needs access to outer variables such as $card and .body. I think we can go ahead with this, for now at least, since it's a net win for easy deduplication either way and we can do this kind of work incrementally.

> [!NOTE]
I'll mark this PR as a draft for a while, as the migration to Hugo 0.152.2 for downstream websites isn't complete yet.

@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for scientific-python-hugo-theme failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 3d75b62
🔍 Latest deploy log https://app.netlify.com/projects/scientific-python-hugo-theme/deploys/698a900b72bc860008a90ea7

@agriyakhetarpal agriyakhetarpal marked this pull request as draft December 31, 2025 23:14
@agriyakhetarpal agriyakhetarpal removed the request for review from stefanv December 31, 2025 23:14
@stefanv
Copy link
Member

stefanv commented Feb 9, 2026

I like the direction this is taking 👍

@stefanv
Copy link
Member

stefanv commented Feb 9, 2026

Also, it's neat that Hugo finally added that feature!

@stefanv
Copy link
Member

stefanv commented Feb 10, 2026

5:55:50 PM: ERROR error building site: render: [en v1.0.0 guest] failed to render pages: render of "/opt/build/repo/blog/content/posts/community-stories/will_tirone/index.md" failed: "/opt/build/scientific-python-hugo-theme/layouts/posts/single.html:2:3": execute of template failed: template: posts/single.html:2:3: executing "main" at <partial "posts/post.html" .>: error calling partial: "/opt/build/scientific-python-hugo-theme/layouts/partials/posts/post.html:3:10": execute of template failed: template: _partials/posts/post.html:3:10: executing "_partials/posts/post.html" at <partial "_decorators/content-container.html" .>: error calling partial: "/opt/build/scientific-python-hugo-theme/layouts/partials/_decorators/content-container.html:7:6": execute of template failed: template: _partials/_decorators/content-container.html:7:6: executing "_partials/_decorators/content-container.html" at <inner .>: error calling inner: template: _partials/posts/post.html:6:14: executing "_partials/_internal/decorator_8e9d3f7b5767b258" at <$featuredImage>: undefined variable: $featuredImage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants