This plugin helps clean up the HTML files in a Docusaurus project. It removes unnecessary meta tags, such as the generator
meta tag, docusaurus_version
meta tag, docusaurus_tag
meta tag, removes data-rh="true"
attributes, and cleans up empty attributes (like class
, target
, title
, alt
) from the generated HTML files.
-
Remove Generator Tag: By default, it removes the
generator
meta tag that Docusaurus inserts. -
Remove Docusaurus Meta Tags: Removes
docusaurus_version
, anddocusaurus_tag
, meta tags. -
Remove DocSearch Meta Tags: Removes
docsearch:version
, anddocsearch:docusaurus_tag
meta tags. -
Remove
data-rh="true"
: Removes thedata-rh="true"
attribute fromtitle
,meta
,link
, andscript
tags. -
Remove Empty Attributes: Cleans up empty attributes like
class
,target
,title
, andalt
.
To install this plugin, run:
npm install docusaurus-plugin-html-cleanup
Once installed, add the plugin to the docusaurus.config.js
:
module.exports = {
plugins: [
[
'docusaurus-plugin-html-cleanup',
{
removeGeneratorTag: true,
removeDocusaurusMetaTags: true,
removeDocSearchMetaTags: true,
removeDataRhTrue: true,
removeEmptyAttributes: true,
},
],
],
};
You can configure the plugin using the following options:
- removeGeneratorTag: Removes the generator meta tag (default: true).
- removeDocusaurusMetaTags: Removes Docusaurus-related meta tags (default: true).
- removeDocSearchMetaTags: Removes Docsearch-related meta tags (default: true).
- removeDataRhTrue: Removes data-rh="true" from meta and link tags (default: true).
- removeEmptyAttributes: Removes empty attributes like class, target, title, and alt (default: true).
The following configuration will disable some functionality:
module.exports = {
plugins: [
[
'docusaurus-plugin-html-cleanup',
{
removeGeneratorTag: false, // Keep the generator tag
},
],
],
};