Search engine optimization (SEO)
Docusaurus supports search engine optimization in a variety of ways.
Global metadata
Provide global meta attributes for the entire site through the site configuration. The metadata will all be rendered in the HTML <head>
using the key-value pairs as the prop name and value.
module.exports = {
themeConfig: {
metadata: [{name: 'keywords', content: 'cooking, blog'}],
// This would become <meta name="keywords" content="cooking, blog"/> in the generated HTML
},
};
Docusaurus adds some metadata out-of-the-box. For example, if you have configured i18n, you will get a hreflang
alternate link.
To read more about types of meta tags, visit the MDN docs.
Single page metadata
Similar to global metadata, Docusaurus also allows for the addition of meta-information to individual pages. Follow this guide for configuring the <head>
tag. In short:
# A cooking guide
<head>
<meta name="keywords" content="cooking, blog"/>
</head>
Some content...
Docusaurus automatically adds description
, title
, canonical URL links, and other useful metadata to each Markdown page. They are configurable through front matter:
---
title: Title for search engines; can be different from the actual heading
description: A short description of this page
image: a thumbnail image to be shown in social media cards
keywords: [keywords, describing, the main topics]
---