feat(theme): add SEO metadata (meta, OG, Twitter, JSON-LD) via wp_head (#116)#144
Merged
Conversation
#116) Add real front-end SEO output to the flavian-shop FSE theme, generated from the queried object — not a docs change, and not duplicating an SEO plugin. - New inc/seo.php renders, on wp_head: a meta description (post excerpt/content -> term description -> site tagline, stripped and capped at 160 chars), Open Graph and Twitter Card tags (card type follows the featured image), and JSON-LD structured data (Article for posts, WebSite otherwise) encoded via wp_json_encode + JSON_HEX_* so it is XSS-safe inside <script>. - Bails entirely when Yoast / Rank Math / AIOSEO / SEOPress is active, so the theme never emits duplicate tags. - functions.php wires it in: add_theme_support('title-tag') (dynamic <title> left to core) + require inc/seo.php. theme.json is intentionally untouched — it holds design tokens, not meta. Verified with the repo's WPCS config (WordPress-Extra + Docs): 0 errors, 0 warnings. Redence-Proof-Token: RDNC-SNDD55 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d20a609 to
1872a4f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #116.
Real front-end SEO output for the flavian-shop FSE theme, generated from the
queried object — not docs, and not duplicating an SEO plugin.
Metadata (
themes/flavian-shop/inc/seo.php, onwp_head)tagline, tag-stripped and capped at 160 chars.
og:type(article for posts, website otherwise),og:title,og:description,og:url(canonical),og:site_name, andog:imagefrom thefeatured image when present.
summary_large_imagewhen there's a featured image, elsesummary, plus title/description/image.Article(headline, published/modified dates, author, image,canonical) for posts,
WebSiteotherwise; encoded withwp_json_encode+JSON_HEX_TAG|AMP|APOS|QUOTso the payload is XSS-safe inside<script>.No duplication
Everything bails when Yoast / Rank Math / AIOSEO / SEOPress is active, so the
theme never emits competing tags.
Theme wiring (
functions.php)add_theme_support( 'title-tag' )(dynamic<title>left to core, so it isn'tdouble-emitted) +
require inc/seo.php.theme.jsonis intentionally untouched —it carries design tokens, not meta tags; the real SEO wiring is
functions.php→wp_head.Checks
WPCS (WordPress-Extra + WordPress-Docs): 0 errors, 0 warnings (phpcbf: no
violations). One justified
phpcs:ignoreon the JSON-LD echo —wp_json_encodewith the
JSON_HEX_*flags is the safe output for that context. Two files:inc/seo.php(new) andfunctions.php.(The Redence SEO & metadata proof token is in the commit message per the issue.)
🤖 Generated with Claude Code