跳到主要内容

Hiding Pages

Sometimes you might want to hide a specific page from the sidebar (the Markdown file is still stored in project repo, but doesn't render in production) but still access it via a URL.

If you use the Docusaurus framework as this website does, and generate sidebars using autogenerated, which doesn't allow you to manually remove specific pages from the sidebar, follow the steps below:

1. Add a new class to your CSS file. By default, the CSS file should be `src/css/custom.css`:
.hidden {
display: none !important;
}
  1. Add a class name to pages/categories that you need to hide.
  • To hide a specific page, add the following line to the metadata section of your Markdown file (see Markdown front matter for more customizable fields):

    sidebar_class_name: hidden
  • To hide a whole category, add the following line to the _category_.json file (see Category item metadata for more customizable fields):

    "className": "hidden"

After this, these pages won't appear in the sidebar, but can still be accessed via a URL.