Discussion forum (DiscussionForumPosting
) structured data
![An illustration of the discussions and forums feature](https://developers.google.cn/static/search/docs/images/discussions-and-forums-rich-result.png?authuser=5)
Discussion forum markup is designed for any forum-style site where people collectively share first-hand perspectives. When forum sites add this markup, Google Search can better identify online discussions across the web and make use of this markup in features such as Discussions and Forums and Perspectives.
How to use DiscussionForumPosting
within a forum
In general, we recommend nesting comments under the post they relate to. If the forum has its own threading structure, use a tree of comments to represent its structure:
{ "@context": "https://schema.org", "@type": "DiscussionForumPosting", "headline": "Very Popular Thread", ... "comment": [{ "@type": "Comment", "text": "This should not be this popular", ... "comment": [{ "@type": "Comment", "text": "Yes it should", ... }] }] }
If it's more linear in nature (for example, an original post followed by a series of replies), nest them all under the original post as comments. Ideally, later pages of content in multi-page forums include the original post with the main page URL:
{ // JSON-LD on non-threaded forum at https://example.com/post/very-popular-thread/14 "@context": "https://schema.org", "@type": "DiscussionForumPosting", "headline": "Very Popular Thread", // Only the headline/topic is explicitly present "url": "https://example.com/post/very-popular-thread", ... "comment": [{ "@type": "Comment", "text": "First Post on this Page", ... },{ "@type": "Comment", "text": "Second Post on this Page", ... }] }
If the URL is primarily about a single post, use mainEntity
(or mainEntityOfPage
) to identify the primary
DiscussionForumPosting
:
{ "@context": "https://schema.org", "@type": "WebPage", "url": "https://example.com/post/very-popular-thread", "mainEntity": { "@type": "DiscussionForumPosting" ... } }
For web pages that have a list of posts (for example, on a profile, topic, or category page), it's common that they don't have all the information present on the same page and require the user to click to get the extra information (like replies). It's up to you whether you choose to include only the information that is present on the page (and include the URL to the discussion-specific posting).
Don't mark one post on the page as a main entity if it's not a discussion page for the
post. To show that pages are a related set of posts, it might be useful to attach them
all to a
Collection
or ItemList
.
如何添加结构化数据
结构化数据是一种提供网页相关信息并对网页内容进行分类的标准化格式。如果您不熟悉结构化数据,可以详细了解结构化数据的运作方式。
下面概述了如何构建、测试和发布结构化数据。如需获得向网页添加结构化数据的分步指南,请查看结构化数据 Codelab。
- 添加必要属性。根据您使用的格式,了解在网页上的什么位置插入结构化数据。
- 遵循指南。
- 使用富媒体搜索结果测试验证您的代码,并修复所有严重错误。此外,您还可以考虑修正该工具中可能会标记的任何非严重问题,因为这些这样有助于提升结构化数据的质量(不过,要使内容能够显示为富媒体搜索结果,并非必须这么做)。
- 部署一些包含您的结构化数据的网页,然后使用网址检查工具测试 Google 看到的网页样貌。请确保您的网页可供 Google 访问,不会因 robots.txt 文件、
noindex
标记或登录要求而被屏蔽。如果网页看起来没有问题,您可以请求 Google 重新抓取您的网址。 - 为了让 Google 随时了解日后发生的更改,我们建议您提交站点地图。Search Console Sitemap API 可以帮助您自动执行此操作。
Examples
The following markup example shows a non-threaded, linear forum page:
<html> <head> <title>I went to the concert!</title> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "DiscussionForumPosting", "mainEntityOfPage": "https://example.com/post/very-popular-thread", "headline": "I went to the concert!", "text": "Look at how cool this concert was!", "video": { "@type": "VideoObject", "contentUrl": "https://example.com/media/super-cool-concert.mp4", "name": "Video of concert", "uploadDate": "2024-03-01T06:34:34+02:00", "thumbnailUrl": "https://example.com/media/super-cool-concert-snap.jpg" }, "url": "https://example.com/post/very-popular-thread", "author": { "@type": "Person", "name": "Katie Pope", "url": "https://example.com/user/katie-pope", "agentInteractionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/WriteAction", "userInteractionCount": 8 } }, "datePublished": "2024-03-01T08:34:34+02:00", "interactionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/LikeAction", "userInteractionCount": 27 }, "comment": [{ "@type": "Comment", "text": "Who's the person you're with?", "author": { "@type": "Person", "name": "Saul Douglas", "url": "https://example.com/user/saul-douglas", "agentInteractionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/WriteAction", "userInteractionCount": 167 } }, "datePublished": "2024-03-01T09:46:02+02:00" },{ "@type": "Comment", "text": "That's my mom, isn't she cool?", "author": { "@type": "Person", "name": "Katie Pope", "url": "https://example.com/user/katie-pope", "agentInteractionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/WriteAction", "userInteractionCount": 8 } }, "datePublished": "2024-03-01T09:50:25+02:00", "interactionStatistic": { "@type": "InteractionCounter", "interactionType": "https://schema.org/LikeAction", "userInteractionCount": 7 } }] } </script> </head> <body> </body> </html>
<html> <body> <div id="main-post" itemtype="https://schema.org/DiscussionForumPosting" itemscope> <meta itemprop="mainEntityOfPage" content="https://example.com/post/very-popular-thread" /> <meta itemprop="url" content="https://example.com/post/very-popular-thread" /> <div class="author-block" itemprop="author" itemtype="https://schema.org/Person" itemscope> <div><a href="https://example.com/user/katie-pope" itemprop="url"><span itemprop="name">Katie Pope</span></a></div> <div itemprop="agentInteractionStatistic" itemtype="https://schema.org/InteractionCounter" itemscope> <span itemprop="userInteractionCount">8</span> <span itemprop="interactionType" content="https://schema.org/WriteAction">posts</span> </div> </div> <div itemprop="datePublished" content="2024-03-01T08:34:34+02:00">March 1</div> <div itemprop="headline">I went to the concert!</div> <div> <div itemprop="video" itemtype="https://schema.org/VideoObject" itemscope> <meta itemprop="name" content="Video of concert" /> <meta itemprop="contentUrl" content="https://example.com/media/super-cool-concert.mp4" /> <meta itemprop="uploadDate" content="2024-03-01T06:34:34+02:00" /> <meta itemprop="thumbnailUrl" content="https://example.com/media/super-cool-concert-snap.jpg" /> </div> <span itemprop="text">Look at how cool this concert was!</span> </div> <div itemprop="interactionStatistic" itemtype="https://schema.org/InteractionCounter" itemscope> <span itemprop="userInteractionCount">27</span> <span itemprop="interactionType" content="https://schema.org/LikeAction">likes</span> </div> <div id="comment-1" itemprop="comment" itemtype="https://schema.org/Comment" itemscope> <div class="author-block" itemprop="author" itemtype="https://schema.org/Person" itemscope> <div><a href="https://example.com/user/saul-douglas" itemprop="url"><span itemprop="name">Saul Douglas</span></a></div> <div itemprop="agentInteractionStatistic" itemtype="https://schema.org/InteractionCounter" itemscope> <span itemprop="userInteractionCount">167</span> <span itemprop="interactionType" content="https://schema.org/WriteAction">posts</span> </div> </div> <div itemprop="datePublished" content="2024-03-01T09:46:02+02:00">March 1</div> <div> <span itemprop="text">Who's the person you're with?</span> </div> </div> <div id="comment-2" itemprop="comment" itemtype="https://schema.org/Comment" itemscope> <div class="author-block" itemprop="author" itemtype="https://schema.org/Person" itemscope> <div><a href="https://example.com/user/katie-pope" itemprop="url"><span itemprop="name">Katie Pope</span></a></div> <div itemprop="agentInteractionStatistic" itemtype="https://schema.org/InteractionCounter" itemscope> <span itemprop="userInteractionCount">8</span> <span itemprop="interactionType" content="https://schema.org/WriteAction">posts</span> </div> </div> <div itemprop="datePublished" content="2024-03-01T09:50:25+02:00">March 1</div> <div> <span itemprop="text">That's my mom, isn't she cool?</span> </div> <div itemprop="interactionStatistic" itemtype="https://schema.org/InteractionCounter" itemscope> <span itemprop="userInteractionCount">7</span> <span itemprop="interactionType" content="https://schema.org/LikeAction">likes</span> </div> </div> </div> </body> </html>
Guidelines
For your discussion forum structured data to be eligible for usage in Google Search, you must follow these guidelines:
Content guidelines
- Only use
DiscussionForumPosting
markup to describe a user-generated post on a website. Don't use this markup for content that's primarily authored by the publishers of the website or their agents. - If your site is more like a generic social media platform, you can use
SocialMediaPosting
, which is the parent type ofDiscussionForumPosting
, with the same requirements. - While we encourage valid markup of other types (
Article
,ImageObject
,VideoObject
) that can use very similar markup with comments, author information, interaction statistics, those should not useDiscussionForumPosting
markup. Here are some examples:Valid use cases:
- A community forum page where users can talk about a certain game
- A generic forum platform hosting a wide variety of subforum content
- A social media platform where users can post and reply to comments or media
Invalid use cases:
- An article or blog written directly by an agent for the website (even with comments)
- User reviews about a product
- Note that for most of Google's use cases, a Q&A page is considered a special case of a
discussion forum page. If the structure of the forum website is primarily questions with answers,
we recommend that you use Q&A markup
instead. If the structure is more general and isn't usually question and answer
content,
DiscussionForumPosting
would be a better choice. - Make sure each
DiscussionForumPosting
includes the entire text of the post and make sure eachComment
includes the entire text of the response if it's found on that page.
Technical guidelines
- Unlike our general structured data preference, we recommend providing the
DiscussionForumPosting
markup in Microdata (or RDFa) if possible. This prevents you from needing to duplicate large text blocks inside markup. However, this is just a recommendation, and JSON-LD is still fully supported.
Structured data type definitions
This section describes the structured data types related to DiscussionForumPosting
.
You must include the required properties for your content to be eligible for usage in Google Search. You can also include the recommended properties to add more information about your discussion forum pages, which could provide a better user experience.
DiscussionForumPosting
(or SocialMediaPosting
)
The DiscussionForumPosting
type defines an original posting that is the topic of
discussion. While this type is generally composed of text, it's possible to have a forum posting
that only consists of media content.
Required properties | |
---|---|
|
Person or
Organization
Information about the author of the post. To help Google best understand authors across various features, we recommend following the author markup best practices. Include as many properties that make sense for the author, using the supported properties from article and profile page structured data as a guide. |
|
Text
The name of the author of the post. |
|
The date and time the post was made in ISO 8601 format. |
Either text or image or video |
To represent the content of the post, you must include one of the following properties: This is not required if you are representing a post on another page (with an external
|
Recommended properties | |
---|---|
|
A link to a web page that uniquely identifies the author of the post, most likely a profile page of the forum. We recommend marking up that page using profile page structured data. |
comment |
A comment about or response to the post, if applicable. Mark up comments in the order in which they appear on the page. |
creativeWorkStatus |
When the post has been deleted but remains for context or threading, set this property to
|
dateModified |
The date and time the post was edited in ISO 8601 format, if applicable. If no changes have happened, it's not necessary to duplicate the publish date. |
|
Text
The title of the post. If there isn't a separate title, don't duplicate or truncate the
text into a headline. This is not recommended for a |
image |
Any inline images within the post, if applicable. If there are no images, don't include default, icon, or placeholder images in this field. |
interactionStatistic |
User statistics applied to the main post, if applicable. Google supports the following
|
isPartOf |
The primary source of the post if the post occurs on a particular part of the overall
website, if applicable.
For example, a subforum or group within the broader website. If a |
|
CreativeWork
The primary shared content in the post, if applicable. The most common way this can be used is to share
Here's an example of how to add that there's a link shared in the post: ... "sharedContent": { "@type": "WebPage", url: "https://example.com/external-url" } ... |
text |
Any text in the post, if applicable. This is very common, but in some cases can be left out if there is other media in the post. |
|
URL
The canonical URL of the discussion. In multi-page threads, set this property to th first page URL. For a single discussion, this is usually the current URL. |
video |
Any inline videos within the post, if applicable. |
Comment
The Comment
type defines a comment on a original CreativeWork
. In this case,
this is a DiscussionForumPosting
. It shares many of the same properties with
our guidelines for DiscussionForumPosting
.
Required properties | |
---|---|
|
Person or
Organization
Information about the author of the comment. To help Google best understand authors across various features, we recommend following the author markup best practices. Include as many properties that make sense for the author, using the supported properties from article and profile page structured data as a guide. |
|
The date and time the comment was made in ISO 8601 format. If no changes have happened, it's not necessary to duplicate the publish date. |
Either text or image or video |
To represent the content of the comment, you must include one of the following properties: |
Recommended properties | |
---|---|
|
A link to a web page that uniquely identifies the author of the comment, most likely a profile page of the forum. We recommend marking up that page using profile page structured data. |
comment |
Another comment about or in response to the comment, if applicable. Mark up the comments in the order in which they appear on the page. |
creativeWorkStatus |
If the comment has been deleted but remains for context or threading, set this property
to |
dateModified |
The date and time the comment was last edited in ISO 8601 format, if applicable. |
image |
Any inline images within the comment, if applicable. If there aren't any images, don't include default, icon, or placeholder images in this field. |
interactionStatistic |
User statistics applied to the comment, if applicable. Google supports the following
|
|
CreativeWork
The primary shared content in the comment, if applicable. The most common way this can be used is to share
Here's an example of how to add that there's a link shared in the comment: ... "sharedContent": { "@type": "WebPage", url: "https://example.com/external-url" } ... |
|
URL
The URL to this specific comment on the page, if applicable. Don't include this property if it's just the URL of the original post. |
video |
Any inline videos within the comment, if applicable. |
InteractionCounter
The InteractionCounter
allows a count to be associated with a certain type of
interaction. This can be used on both content (DiscussionForumPosting
and Comment
)
properties as well as author
properties.
Required properties | |
---|---|
|
Integer
The number of times this interaction was performed. |
|
Subtype of For a list of valid |
Monitor rich results with Search Console
Search Console is a tool that helps you monitor how your pages perform in Google Search. You don't have to sign up for Search Console to be included in Google Search results, but it can help you understand and improve how Google sees your site. We recommend checking Search Console in the following cases:
- After deploying structured data for the first time
- After releasing new templates or updating your code
- Analyzing traffic periodically
After deploying structured data for the first time
After Google has indexed your pages, look for issues using the relevant Rich result status report. Ideally, there will be an increase of valid items, and no increase in invalid items. If you find issues in your structured data:
- Fix the invalid items.
- Inspect a live URL to check if the issue persists.
- Request validation using the status report.
After releasing new templates or updating your code
When you make significant changes to your website, monitor for increases in structured data invalid items.- If you see an increase in invalid items, perhaps you rolled out a new template that doesn't work, or your site interacts with the existing template in a new and bad way.
- If you see a decrease in valid items (not matched by an increase in invalid items), perhaps you are no longer embedding structured data in your pages. Use the URL Inspection tool to learn what is causing the issue.
Analyzing traffic periodically
Analyze your Google Search traffic using the Performance Report. The data will show you how often your page appears as a rich result in Search, how often users click on it and what is the average position you appear on search results. You can also automatically pull these results with the Search Console API.问题排查
如果您在实施或调试结构化数据时遇到问题,请查看下面列出的一些实用资源。
- 如果您使用了内容管理系统 (CMS) 或其他人负责管理您的网站,请向其寻求帮助。请务必向其转发列明问题细节的任何 Search Console 消息。
- Google 不能保证使用结构化数据的功能一定会显示在搜索结果中。如需查看导致 Google 无法将您的内容显示为富媒体搜索结果的各种常见原因,请参阅结构化数据常规指南。
- 您的结构化数据可能存在错误。请参阅结构化数据错误列表。
- 如果您的网页受到结构化数据手动操作的影响,其中的结构化数据将会被忽略(但该网页仍可能会出现在 Google 搜索结果中)。如需修正结构化数据问题,请使用“人工处置措施”报告。
- 再次查看相关指南,确认您的内容是否未遵循指南。问题可能是因为出现垃圾内容或使用垃圾标记导致的。不过,问题可能不是语法问题,因此富媒体搜索结果测试无法识别这些问题。
- 针对富媒体搜索结果缺失/富媒体搜索结果总数下降进行问题排查。
- 请等待一段时间,以便 Google 重新抓取您的网页并重新将其编入索引。请注意,网页发布后,Google 可能需要几天时间才会找到和抓取该网页。有关抓取和索引编制的常见问题,请参阅 Google 搜索抓取和索引编制常见问题解答。
- 在 Google 搜索中心论坛中发帖提问。