Skip to content

Extract shared head template from themes#526

Merged
compscidr merged 2 commits intomainfrom
feature/shared-head-template
Mar 19, 2026
Merged

Extract shared head template from themes#526
compscidr merged 2 commits intomainfrom
feature/shared-head-template

Conversation

@compscidr
Copy link
Collaborator

Summary

  • Move all <head> content (meta tags, OG, structured data, CDN imports) into a shared templates/shared/_head.html template
  • Theme headers now just call {{ template "_head" . }} then define their own <body> and navigation
  • Removes ~225 lines of duplicated HTML across three themes
  • Adds site_url setting so OG/structured data URLs are configurable per instance (replaces hardcoded https://www.jasonernst.com)
  • Adds robots_tag setting (default: index, follow) so staging instances can set noindex, nofollow

Test plan

  • All existing tests pass
  • Verify pages render correctly with default, minimal, and forest themes
  • Set robots_tag to noindex, nofollow on staging and verify meta tag appears
  • Set site_url and verify OG tags use it

🤖 Generated with Claude Code

Move all <head> content (meta tags, OG, structured data, CDN imports)
into a shared _head.html template loaded alongside any theme. Themes
now only control <body> layout and navigation. Adds site_url and
robots_tag settings so OG URLs and indexing are configurable per
instance rather than hardcoded.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 19, 2026 17:29
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes duplicated <head> markup across themes into a shared template and adds configurable settings to support per-instance SEO metadata.

Changes:

  • Added templates/shared/_head.html and updated themes to call {{ template "_head" . }}.
  • Added new settings robots_tag and site_url to default settings seeding.
  • Updated template loading (and tests) to parse shared templates before theme templates.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/migrate.go Seeds new robots_tag/site_url settings.
themes/minimal/templates/header.html Replaces inline <head> with shared _head template call.
themes/forest/templates/header.html Replaces inline <head> with shared _head template call.
themes/default/templates/header.html Replaces inline <head> with shared _head template call.
templates/shared/_head.html New shared head template containing meta/OG/JSON-LD/CDN imports.
goblog.go Loads shared templates first, then theme templates; updates fallback behavior.
blog/blog_test.go Updates test template loading to include shared templates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fail fast (log.Fatalf) when shared templates fail to load, since all
  themes depend on _head being available
- Seed site_url with https://www.example.com instead of empty string,
  so OG/structured data URLs are always absolute
- Fall back to "index, follow" when robots_tag value is empty, not just
  when the setting key is missing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@compscidr compscidr merged commit f8be04f into main Mar 19, 2026
1 check passed
@compscidr compscidr deleted the feature/shared-head-template branch March 19, 2026 17:53
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.

2 participants