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:
- Use a CSS class
- Use the src/pages folder
.hidden {
display: none !important;
}
- 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.
You can also put the pages (such as .md
and .js
) that you want to hide in the src/pages
folder. Pages in this folder won't appear in the sidebar, but can still be accessed via a URL.
If you have multiple versions whose URLs are in the format of <domain>/v1.1/hello-world
and <domain>/v1.2/hello-world
, you can also create folders called v1.1
and v1.2
in the pages
folders to make the URL format consistent.