Skip to content

Add partial decorators for better composability#692

Open
agriyakhetarpal wants to merge 13 commits intoscientific-python:mainfrom
agriyakhetarpal:partial-decorators
Open

Add partial decorators for better composability#692
agriyakhetarpal wants to merge 13 commits intoscientific-python:mainfrom
agriyakhetarpal:partial-decorators

Conversation

@agriyakhetarpal
Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal commented Dec 31, 2025

This PR introduces 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. 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 v0.157.0 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 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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 31, 2025

Deploy Preview for scientific-python-hugo-theme ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 76a3d1c
🔍 Latest deploy log https://app.netlify.com/projects/scientific-python-hugo-theme/deploys/69ec1d4972ad2b0008e83c45
😎 Deploy Preview https://deploy-preview-692--scientific-python-hugo-theme.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94
Accessibility: 97
Best Practices: 100
SEO: 91
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@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
Copy Markdown
Member

stefanv commented Feb 9, 2026

I like the direction this is taking 👍

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Feb 9, 2026

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

@stefanv
Copy link
Copy Markdown
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

@agriyakhetarpal agriyakhetarpal changed the title A start towards partial decorators for better composability Add partial decorators for better composability Mar 11, 2026
@agriyakhetarpal
Copy link
Copy Markdown
Member Author

agriyakhetarpal commented Mar 11, 2026

Restarting CI to see why Netlify is stuck

Edit: I'm just going to assume it is down, but will mark this as ready for review anyway.

@agriyakhetarpal agriyakhetarpal marked this pull request as ready for review March 11, 2026 07:20
@agriyakhetarpal agriyakhetarpal requested a review from stefanv March 11, 2026 07:20
@agriyakhetarpal agriyakhetarpal added this to the 0.23 milestone Mar 11, 2026
@stefanv
Copy link
Copy Markdown
Member

stefanv commented Apr 25, 2026

Needs Authors update

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

The atom feed template uses site.Author, which was deprecated in Hugo v0.124: gohugoio/hugo#12269, and removed in later versions. I bumped to Hugo 0.158.0 in the last few commits, so we're probably too new. I don't think we should downgrade the Hugo version, ever. I'll override this for now in our layouts, but since this has been raised: why do we need hugo-atom-feed anyway? Personally, I don't mind RSS feeds, and it looks like https://github.com/kaushalmodi/hugo-atom-feed hasn't received much activity either. So if we want to keep it, we should fork it into scientific-python and maintain it for a while (which I have no qualms doing).

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

We can switch to yelosan/hugo-feeds on Codeberg. It looks like it's a bit better maintained (but still not maintained well enough, though). See yelosan/hugo-feeds (GitHub mirror) too.

Another one I found is https://github.com/hugo-fixit/hugo-atom-feed, which last worked with Hugo v0.146.7.

Honestly, I'm tempted to drop it, but reading #489 and #497, I see that we did have a fork of this subtheme in the past.

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Apr 25, 2026

How about we submit a patch first and see if it gets accepted?

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Apr 25, 2026

(We can merge, using a fork of our own for now.)

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

I can open up a PR tomorrow evening, sure. I won't suggest using a fork of the theme for merging this PR, though, because the change isn't that substantial – I only copied the file into layouts/ verbatim from the theme and applied my changes. The actual diff is tiny:

diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml
index 3e610c3..40005d1 100644
--- a/layouts/_default/list.atom.xml
+++ b/layouts/_default/list.atom.xml
@@ -50,14 +50,16 @@
             <logo>{{ (. | fingerprint).Permalink }}</logo>
         {{- end }}
     {{ end }}
-    {{ with site.Author.name -}}
-        <author>
-            <name>{{ . }}</name>
-            {{ with site.Author.email }}
-                <email>{{ . }}</email>
-            {{ end -}}
-        </author>
-    {{- end }}
+    {{ with site.Params.author }}
+        {{ with .name -}}
+            <author>
+                <name>{{ . }}</name>
+                {{ with $.Site.Params.author.email }}
+                    <email>{{ . }}</email>
+                {{ end -}}
+            </author>
+        {{- end }}
+    {{ end }}
     {{ with site.Params.id }}
         <id>{{ . | plainify }}</id>
     {{ else }}
@@ -92,8 +94,8 @@
             {{ else }}
                 <id>{{ .Permalink }}</id>
             {{ end }}
-            {{ with .Params.author -}}
-                {{- range . -}} <!-- Assuming the author front-matter to be a list -->
+            {{ with .Params.authors -}}
+                {{- range . -}}
                     <author>
                         <name>{{ . }}</name>
                     </author>

I can note these changed hunks in a comment if you'd like me to, but a fork is pretty overkill 😅

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