feat(seo): FAQPage structured data on blog posts
CI/CD / CI · dotnet build (push) Successful in 16m5s
CI/CD / Deploy · drsousan (push) Successful in 29s

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:
soroush.asadi
2026-06-26 01:02:44 +03:30
parent f3701c5893
commit 1c9d8cdc1b
2 changed files with 43 additions and 0 deletions
+17
View File
@@ -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}