用于论坛的 JSON-LD:DiscussionForumPosting 和 BreadcrumbList 而不是 FAQPage
为什么不常见问题页面
一个流行的技巧是在论坛帖子上发布 DiscussionForumPosting + FAQPage + BreadcrumbList 以在搜索结果中获取扩展问题。它已经过时了。截至 2023 年 8 月,Google 仅显示已知权威政府和健康网站的丰富常见问题解答结果。对于论坛来说,FAQPage 标记不会产生片段,如果其中的问题与页面分开编写,则违反了结构化数据的规则。
FAQPage 本质上描述了一个页面,网站所有者自己在其中提出问题并亲自回答。论坛主题则不同:用户发布消息,其他人回复。为此,Google 有一个单独的类型,支持搜索 - DiscussionForumPosting。如果线程被构造为单个问题并选择最佳答案,那么 QAPage 是合适的。
任何类型的主要规则:标记描述用户在页面上看到的内容。 JSON-LD 中的作者、日期、文本和响应必须与可见内容匹配。
讨论论坛发帖的最低要求
根据 Google 文档,需要 author、datePublished 以及 text、image 或 video 中的至少一项。推荐为 headline、url、dateModified、comment、interactionStatistic。
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"headline": "Docker обходит UFW: как закрыть порт базы",
"url": "https://example.com/ru/forum/docker-ufw",
"datePublished": "2026-11-17T09:03:00+00:00",
"dateModified": "2026-11-17T12:40:00+00:00",
"author": {
"@type": "Person",
"name": "anna_dev",
"url": "https://example.com/ru/u/anna_dev"
},
"text": "На сервере включён UFW, но порт 5432 доступен снаружи...",
"interactionStatistic": [
{ "@type": "InteractionCounter", "interactionType": "https://schema.org/LikeAction", "userInteractionCount": 12 },
{ "@type": "InteractionCounter", "interactionType": "https://schema.org/WriteAction", "userInteractionCount": 3 }
],
"comment": [
{
"@type": "Comment",
"author": { "@type": "Person", "name": "ops_kz", "url": "https://example.com/ru/u/ops_kz" },
"datePublished": "2026-11-17T10:15:00+00:00",
"text": "Проверьте цепочку DOCKER-USER, правила UFW туда не попадают."
}
]
}日期采用带时区的 ISO 8601 格式。 text - 页面上可见的相同文本;你可以切断它,但你无法发明它。在 comment 中仅放置此页面上显示的答案:如果答案分为几页,请将您自己的答案放在第二页上。
面包屑列表
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Форум", "item": "https://example.com/ru/forum" },
{ "@type": "ListItem", "position": 2, "name": "Безопасность", "item": "https://example.com/ru/forum?category=security" },
{ "@type": "ListItem", "position": 3, "name": "Docker обходит UFW" }
]
}最后一个元素是当前页面;不必指定 item。标记中的碎屑应该与可见的导航相匹配。如果页面没有面包屑,请从面包屑开始,而不是 JSON-LD。
输出到 Next.js 应用程序路由器
// app/[locale]/forum/[slug]/JsonLd.tsx
type Thread = {
title: string; url: string; body: string; createdAt: string; updatedAt?: string;
author: { name: string; url: string };
replies: { author: { name: string; url: string }; createdAt: string; body: string }[];
likes: number;
};
export function ThreadJsonLd({ t, crumbs }: { t: Thread; crumbs: { name: string; url?: string }[] }) {
const graph = [
{
"@type": "DiscussionForumPosting",
headline: t.title,
url: t.url,
datePublished: t.createdAt,
...(t.updatedAt && { dateModified: t.updatedAt }),
author: { "@type": "Person", ...t.author },
text: t.body.slice(0, 5000),
interactionStatistic: [
{ "@type": "InteractionCounter", interactionType: "https://schema.org/LikeAction", userInteractionCount: t.likes },
{ "@type": "InteractionCounter", interactionType: "https://schema.org/WriteAction", userInteractionCount: t.replies.length },
],
comment: t.replies.map((r) => ({
"@type": "Comment",
author: { "@type": "Person", ...r.author },
datePublished: r.createdAt,
text: r.body,
})),
},
{
"@type": "BreadcrumbList",
itemListElement: crumbs.map((c, i) => ({
"@type": "ListItem", position: i + 1, name: c.name, ...(c.url && { item: c.url }),
})),
},
];
const json = JSON.stringify({ "@context": "https://schema.org", "@graph": graph });
return (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: json.replace(/</g, "\\u003c") }}
/>
);
}将 < 替换为 < 是强制性的:在消息文本中,用户可以编写他们想要的任何内容,并且 </script><script>... 行将关闭标记并作为代码执行。搜索引擎的 JSON 解析器将正确读取转义形式。
对于输入,您可以连接 schema-dts 包 - 它会在编译阶段捕获属性名称中的拼写错误。
社论不是论坛帖子
Google 明确声明 DiscussionForumPosting 适用于用户生成的内容。如果该主题是由网站编辑作为指南文章编写的,则具有相同作者和日期的 Article(或 TechArticle)更为正确。在混合论坛上,根据文本的来源选择类型:参与者的出版物是论坛帖子,编辑材料是文章。
如何检查
- 丰富结果测试 显示类型是否被识别以及缺少哪些必填字段。检查 URL,而不是插入的片段:这样您就可以看到服务器实际返回的内容。
- 模式标记验证器 (validator.schema.org) 检查整个 schema.org 词汇表,包括 Google 在代码片段中不支持的类型。
- 当 Google 在页面上发现论坛标记时,搜索控制台中将显示有关论坛标记的报告。在那里您可以看到整个网站的错误,而不仅仅是某一页上的错误。
常见错误
- 一个实体有两个 JSON-LD 块:一个来自布局,另一个来自页面。搜索引擎看到两种不同的出版物。
- 标记中的
author.name是个人资料中的真实姓名,昵称显示在页面上。这是一个差异。 datePublished取自构建时间或上次更改时间,而不是发布时间。interactionStatistic计数器缓存在每日布局中,与可见计数器不同。
当标记不起作用时
结构化数据并不能弥补单薄的内容。通过正确的 JSON-LD,没有回复的单行线程不会变得更加明显。首先是有用的讨论和正常的索引,然后是描述它们的标记。