Skip to content

feat: add extend_post_content.html hook partials for post sections#1846

Open
henrypham67 wants to merge 1 commit intoadityatelange:masterfrom
henrypham67:feat/extend-single-partials
Open

feat: add extend_post_content.html hook partials for post sections#1846
henrypham67 wants to merge 1 commit intoadityatelange:masterfrom
henrypham67:feat/extend-single-partials

Conversation

@henrypham67
Copy link
Copy Markdown

What does this PR change? What problem does it solve?

Adds an extend_post_content.html hook partial at a key injection point in single.html, after the post body and before the footer.

Currently, injecting custom content into single.html (e.g., quizzes, flashcard widgets, custom sections after post body) requires copying the entire layouts/_default/single.html into the project as a full override. This creates an ongoing maintenance burden — every upstream change to single.html requires a manual diff and re-merge.

This PR adds a single no-op stub partial that users can override in their own layouts/partials/ without touching the base layout:

{{- partial "extend_post_content.html" . }}

The stub ships empty (comments only), so existing sites are completely unaffected. This follows the same pattern already established by extend_head.html and extend_footer.html in PaperMod.

Was the change discussed in an issue or in the Discussions before?

Yes. Closes #1845

PR Checklist

  • This change adds/updates translations and I have used the template present here.
  • I have enabled maintainer edits for this PR.
  • I have verified that the code works as described/as intended.
  • This change adds a Social Icon which has a permissive license to use it.
  • This change does not include any CDN resources/links.
  • This change does not include any unrelated scripts such as bash and python scripts.
  • This change updates the overridden internal templates from HUGO's repository.

Commit quality assessment: The commit is solid — minimal, focused, zero-breaking-changes, and consistent with PaperMod's existing extend_head.html / extend_footer.html pattern. The stub file comments clearly explain the purpose and override mechanism. Good to go.

@sonarqubecloud
Copy link
Copy Markdown

@adityatelange
Copy link
Copy Markdown
Owner

use comments.html?

@henrypham67
Copy link
Copy Markdown
Author

Thanks for the suggestion! I considered using comments.html as a hook, but it felt like the wrong trade-off — PaperMod only renders it when comments: true is set in frontmatter, which would be semantically misleading for my use case (flashcards/quiz content). It'd also create a collision point if real comment support (Disqus, utterances, etc.) is added later.
The current single.html override is minimal (two if blocks) and follows standard Hugo layout extension patterns. Keeping the concern in its own partial is cleaner than repurposing a comments hook for unrelated UI. Happy to discuss further if you see a downside I'm missing!

@adityatelange
Copy link
Copy Markdown
Owner

it is not about how minimal the change is but about how many extend templates we can add for each template which user is not wiling to override for their own convenience.

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.

[Enhancement]: partial injection hooks in single.html to avoid full layout overrides

2 participants