跳至主要內容
版本:3.5.2

標題元資料

自訂 head metadata

Docusaurus 會自動設定有用的頁面元資料在 <html><head><body> 中。您可以使用 Markdown 檔案中的<head> 標籤來新增額外的元資料(或覆寫現有的元資料)

markdown-features-head-metadata.mdx
---
id: head-metadata
title: Head Metadata
---

<head>
<html className="some-extra-html-class" />
<body className="other-extra-body-class" />
<title>Head Metadata customized title!</title>
<meta charSet="utf-8" />
<meta name="twitter:card" content="summary" />
<link rel="canonical" href="https://docusaurus.dev.org.tw/docs/markdown-features/head-metadata" />
</head>

# Head Metadata

My text

已在這個 Markdown 文件中新增這個 <head> 宣告作為示範。開啟瀏覽器的 DevTools 並查看這個網頁的元資料是如何受到影響的。

備註

此功能建構在 Docusaurus <Head> 元件之上。有關詳細說明,請參閱 react-helmet

通常的搜尋引擎最佳化 (SEO) 並不需要它

內容外掛程式 (例如文件和部落格) 提供許多前置設定選項,如 descriptionkeywordsimage,這些選項會自動套用到 descriptionog:description,而使用 <head> 標籤時,必須手動宣告 2 個元資料標籤。

Markdown 頁面說明

Markdown 頁面的說明元資料可能用於超過頁面標題元資料的地方。例如,文件外掛程式的 產生的分類索引 使用文件卡片的說明元資料。

一般來說,說明是第一行有內容的文字,並經過一些處理轉換為純文字。例如,下列檔案...

# Title

Main content... May contain some [links](./file.mdx) or **emphasis**.

...的預設說明會是「主要內容...可能包含一些連結或重點」。不過,它並非完全符合規格設計。如果無法產生合理的說明,您可以透過前置設定明確提供說明

---
description: This description will override the default.
---

# Title

Main content... May contain some [links](./file.mdx) or **emphasis**.