使用 <section> 和 <article> 进行 SEO 的正确方法

The right way to use <section> and <article> for SEO

如有拼写错误请见谅,请指正。

我不知道如何使用这两个元素 (Article | Section) 现在我想启动一个具有完全标准 HTML 代码的网站, 现在,您认为我网站上的文章应该如何构建?我可以把网站 header 放在哪里更好? 我被困在这两个选项之间。

<!-- 1 -->
<section>
    <header>
        <h1>title of page</h1>
    </header>
    <article>
        <p>some text</p>
    </article>
</section>

<!-- 2 -->
<section>
    <article>
        <header>
            <h1>title of page</h1>
        </header>
    </article>
    <p>some text</p>
</section>

如果两者都不正确,你有什么建议?

我的英语很差。所以我不能再使用任何问题了。但我理解编码。请通过写代码和简单的句子向我解释,不要说你的问题有答案。

阅读有关 Mozilla 的 HTML element article 的更多信息:

The HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication)... each post would be contained in an element, possibly with one or more s within.

article 元素不同,section element:

The HTML element represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it.

因此,article 元素可以包含section 元素。但是 section 元素不能包含任何其他语义元素。

因此,您的示例可以这样表示:

<header>
 <h1>The article News from Valinor of Gandalf</h1>
</header>
<article>
  <h2>News from Valinor</h2>
  <p>A short introduction to the content of the article.</p>
  <section>
    <h3>The name of section</h3>
    <p>The content of section.</p>
  </section>
  <section>
    <h3>The name of section</h3>
    <p>The content of section.</p>
  </section>
  ...
</article>
<footer>
 <h2>Publisher and copyright holder</h2>
 <p>Publisher and © 2021 Gandalf</p>
</footer>