搜索引擎优化(SEO)_1

编辑:佚名 日期:2024-04-22 14:03 / 人气:


Docusaurus 以多种方式支持搜索引擎优化。

Docusaurus supports search engine optimization in a variety of ways.

通过 站点配置.0 为整个站点提供全局元属性。 元数据将全部使用键值对作为 prop 名称和值在 HTML 中渲染。 属性是声明 标签的便捷快捷方式,但也可以使用 属性在 中注入任意标签。

Provide global meta attributes for the entire site through the site configuration. The metadata will all be rendered in the HTML using the key-value pairs as the prop name and value. The attribute is a convenient shortcut to declare tags, but it is also possible to inject arbitrary tags in with the attribute.

docusaurus.config.js

Docusaurus 添加了一些开箱即用的元数据。 例如,如果你配置了 i18n,你将获得 备用链接。

Docusaurus adds some metadata out-of-the-box. For example, if you have configured i18n, you will get a alternate link.

要了解有关元标记类型的更多信息,请访问 MDN 文档

To read more about types of meta tags, visit the MDN docs.

全局元数据 类似,Docusaurus 也允许向各个页面添加元信息。 按照 本指南 配置 标签。 简而言之:

Similar to global metadata, Docusaurus also allows for the addition of meta-information to individual pages. Follow this guide for configuring the tag. In short:

my-markdown-page.md

Docusaurus 会自动将 、、规范 URL 链接和其他有用的元数据添加到每个 Markdown 页面。 它们可通过 头条新闻 配置:

Docusaurus automatically adds , , canonical URL links, and other useful metadata to each Markdown page. They are configurable through front matter:

创建 React 页面时,在 中添加这些字段也会改善 SEO。

When creating your React page, adding these fields in would also improve SEO.

提示

首选将 头条新闻 用于 和 等字段: Docusaurus 会自动将其应用于 和 ,而你在使用 标签时必须手动声明两个元数据标签。

Prefer to use front matter for fields like and : Docusaurus will automatically apply this to both and , while you would have to manually declare two metadata tags when using the tag.

信息

官方插件均支持以下 头条新闻: 、、 和 。 有关其他 头条新闻 支持,请参阅各自的 API 文档:

The official plugins all support the following front matter: , , and . Refer to their respective API documentation for additional front matter support:

对于 JSX 页面,你可以使用 Docusaurus 组件。

For JSX pages, you can use the Docusaurus component.

my-react-page.jsx
提示

为了方便起见,默认主题 组件接受 和 作为 props。

For convenience, the default theme component accept and as props.

Docusaurus 是一个静态站点生成器—HTML 文件是为每个 URL 路由静态生成的,这有助于搜索引擎更轻松地发现你的内容。

Docusaurus is a static site generator—HTML files are statically generated for every URL route, which helps search engines discover your content more easily.

图片的 alt 标签告诉搜索引擎该图片的内容,并且在无法直观地看到图片时使用,例如 使用屏幕阅读器或图片损坏时。 Markdown 中通常支持 Alt 标签。

The alt tag for an image tells the search engine what the image is about, and is used when the image can't be visually seen, e.g. when using a screen reader, or when the image is broken. Alt tags are commonly supported in Markdown.

你还可以为你的图片添加标题—这不会对 SEO 产生太大影响,但当鼠标悬停在图片上方时会显示为工具提示,通常用于提供提示。

You may also add a title for your image—this doesn't impact SEO much but is displayed as a tooltip when hovering above the image, usually used to provide hints.

http://localhost:3000

Docusaurus banner

Docusaurus 博客支持 丰富的搜索结果 开箱即用,以获得最大的搜索引擎体验。 该信息是根据博客/全局配置中的元信息创建的。 为了获得丰富的搜索信息的好处,请填写有关帖子的发布日期、作者和图片等信息。阅读有关元信息 此处 的更多信息。

Docusaurus blogs support rich search results out-of-the-box to get maximum search engine experience. The information is created depending on your meta information in blog/global configuration. In order to get the benefits of the rich search information, fill in the information about the post's publish date, authors, and image, etc. Read more about the meta-information here.

文件规定搜索引擎的行为,即哪些内容应该显示,哪些内容不应该显示。 你可以将其提供为 静态资源。 以下将允许从所有请求访问所有子页面:

A file regulates search engines' behavior about which should be displayed and which shouldn't. You can provide it as static asset. The following would allow access to all sub-pages from all requests:

static/robots.txt

阅读 谷歌文档 中有关 robots 文件的更多信息。

Read more about the robots file in the Google documentation.

警告

重要的: 文件确实 not 阻止 HTML 页面被索引。

Important: the file does not prevent HTML pages from being indexed.

要防止整个 Docusaurus 站点被索引,请使用 站点配置。 某些 托管服务提供商 还可能让你配置 HTTP 标头(GitHub Pages 不支持此功能)。

To prevent your whole Docusaurus site from being indexed, use the site config. Some hosting providers may also let you configure a HTTP header (GitHub Pages does not support this).

要防止单个页面被索引,请使用 作为 页面元数据。 了解有关 机器人元标签 的更多信息。

To prevent a single page from being indexed, use as page metadata. Read more about the robots meta tag.

Docusaurus 提供了 插件,默认情况下随 一起提供。 它会自动生成一个 文件,该文件将在生产版本后的 可用。 此站点地图元数据可帮助搜索引擎抓取工具更准确地抓取你的网站。

Docusaurus provides the plugin, which is shipped with by default. It autogenerates a file which will be available at after the production build. This sitemap metadata helps search engine crawlers crawl your site more accurately.

提示

站点地图插件会自动过滤包含 机器人元指令 的页面。

The sitemap plugin automatically filters pages containing a robots meta directive.

例如, 不包含在 Docusaurus sitemap.xml 文件 中,因为它包含以下 页面元数据

For example, is not included in the Docusaurus sitemap.xml file because it contains the following page metadata:

Docusaurus 使用你的文件名作为链接,但你始终可以使用 slugs 进行更改,请参阅此 tutorial 了解更多详细信息。

Docusaurus uses your file names as links, but you can always change that using slugs, see this tutorial for more details.

搜索引擎依靠 、 等 HTML 标记来了解网页的结构。 当 Docusaurus 渲染页面时,语义标记,例如 、、 用于划分页面的不同部分,帮助搜索引擎定位侧边栏、导航栏和主页内容等部分。

Search engines rely on the HTML markup such as , , etc., to understand the structure of your webpage. When Docusaurus renders your pages, semantic markup, e.g. , , , are used to divide the different sections of the page, helping the search engine to locate parts like sidebar, navbar, and the main page content.

大多数 CommonMark 语法都有相应的 HTML 标签。 通过在项目中一致使用 Markdown,你将使搜索引擎更容易理解你的页面内容。

Most CommonMark syntaxes have their corresponding HTML tags. By using Markdown consistently in your project, you will make it easier for search engines to understand your page content.


现在致电 13988889999 OR 查看更多联系方式 →

Top 回顶部

平台注册入口