feat(seo): FAQPage structured data on blog posts
Extracts Q/A pairs from the post body (an <h3> ending in the Persian question mark ؟ followed by the next <p>) and emits FAQPage JSON-LD in <head>. Makes posts with FAQ sections eligible for FAQ rich results in Google. Non-question <h3> headings are ignored. Verified: post with 3 h3s emits exactly 2 Question entries (the plain heading excluded), valid escaped JSON. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,23 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
@if (Model.Faqs.Any())
|
||||
{
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@@context": "https://schema.org",
|
||||
"@@type": "FAQPage",
|
||||
"mainEntity": [
|
||||
@for (int i = 0; i < Model.Faqs.Count; i++)
|
||||
{
|
||||
var f = Model.Faqs[i];
|
||||
@:{ "@@type": "Question", "name": "@J(f.Q)", "acceptedAnswer": { "@@type": "Answer", "text": "@J(f.A)" } }@(i < Model.Faqs.Count - 1 ? "," : "")
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
<style>
|
||||
/* ─── Post Layout ──────────────────────────────────────────────── */
|
||||
.post-layout{max-width:1100px;margin:0 auto;padding:5rem 2rem 3rem;display:grid;grid-template-columns:1fr 320px;gap:3rem;align-items:start}
|
||||
|
||||
Reference in New Issue
Block a user