【问题标题】:Semantic markup for a forum's topic page论坛主题页面的语义标记
【发布时间】:2018-05-20 09:31:23
【问题描述】:

你知道,我有一个大型论坛,每个主题有 n 条消息。第一条消息用于包含主题的主要内容,但有时一些消息也非常有用。一个常见的情况是当第一条消息是一个问题,然后你得到答案。

主题应该是article 元素和消息article 元素继承自主题文章吗?在这种情况下,第一条消息是否应该出现在每条消息的页面中作为参考?那么,如何处理重复的内容?

一个例子:

<article itemscope itemtype="http://schema.org/Article">
   <header>
      <h1 itemprop="name">My topic title</h1>
   </header>
   <article itemscope itemtype="http://schema.org/Article">
      <div class="author" itemprop="author">Message author's name</div>
      <div class="message-body" itemprop="articleBody">
         message text bla bla
      </div>
      <p class="post-date" itemprop="dateModified" content="date">date</p>
   </article>
   <article itemscope itemtype="http://schema.org/Article">
      <div class="author" itemprop="author">Message 2 author's name</div>
      <div class="message-body" itemprop="articleBody">
         message 2 text bla bla
      </div>
      <p class="post-date" itemprop="dateModified" content="date">date</p>
   </article>
   ... more messages ...
</article>

这是语义、可访问性和 SEO 的良好做法吗?有没有更好的选择?

【问题讨论】:

  • 这个问题似乎离题了,因为它不在帮助中心所述的讨论范围内。
  • @Will:为什么会跑题?在评论中说明具体原因会很有帮助,否则 OP 很难改进这个问题。 -- 你的意思是“和 SEO”部分吗?如果是的话,把这两个词删掉不是更好吗?
  • “这对于语义、可访问性和 SEO 来说是一个好的做法吗?我还有什么更好的选择吗?” 这是关于 SEO 的工作原理。去阅读seo标签维基。
  • @Will:这三个方面中有两个是切题的(语义标记、可访问性)。第三个方面 (SEO) 对这个问题甚至不是必不可少的,而且很容易编辑。

标签: html forum semantic-markup microdata


【解决方案1】:

每个帖子都应该是article。没有其他东西应该是article。所以主题的标题应该是第一篇文章的一部分,而不是容器的一部分。

您可以将回复嵌套在第一个帖子中,也可以将所有帖子放在同一级别。 HTML 5.2 about article:

article元素嵌套时,内部article元素代表原则上与外部文章内容相关的文章。

对于作者窗格,您可以使用footer 元素。

您可能希望使用更具体的 DiscussionForumPosting 类型(继承自 Article),而不是使用 Schema.org 的 Article 类型。

嵌套

<article>
  <h2>My topic title</h2>
  <footer>…</footer>
  <div>…</div>

  <article>
    <h3>Reply: My topic title</h3>
    <footer>…</footer>
    <div>…</div>
  </article>

  <article>
    <h3>Reply: My topic title</h3>
    <footer>…</footer>
    <div>…</div>
  </article>

</article>

同级

<article>
  <h2>My topic title</h2>
  <footer>…</footer>
  <div>…</div>
</article>

<article>
  <h2>Reply: My topic title</h2>
  <footer>…</footer>
  <div>…</div>
</article>

<article>
  <h2>Reply: My topic title</h2>
  <footer>…</footer>
  <div>…</div>
</article>

【讨论】:

    猜你喜欢
    • 2012-10-28
    • 2017-01-04
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-31
    • 2014-03-25
    相关资源
    最近更新 更多