manage-docs-versions.mdx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. sidebar_position: 1
  3. ---
  4. # Manage Docs Versions
  5. Docusaurus can manage multiple versions of your docs.
  6. ## Create a docs version
  7. Release a version 1.0 of your project:
  8. ```bash
  9. npm run docusaurus docs:version 1.0
  10. ```
  11. The `docs` folder is copied into `versioned_docs/version-1.0` and `versions.json` is created.
  12. Your docs now have 2 versions:
  13. - `1.0` at `http://localhost:3000/docs/` for the version 1.0 docs
  14. - `current` at `http://localhost:3000/docs/next/` for the **upcoming, unreleased docs**
  15. ## Add a Version Dropdown
  16. To navigate seamlessly across versions, add a version dropdown.
  17. Modify the `docusaurus.config.js` file:
  18. ```js title="docusaurus.config.js"
  19. export default {
  20. themeConfig: {
  21. navbar: {
  22. items: [
  23. // highlight-start
  24. {
  25. type: 'docsVersionDropdown',
  26. },
  27. // highlight-end
  28. ],
  29. },
  30. },
  31. };
  32. ```
  33. The docs version dropdown appears in your navbar:
  34. ![Docs Version Dropdown](./img/docsVersionDropdown.png)
  35. ## Update an existing version
  36. It is possible to edit versioned docs in their respective folder:
  37. - `versioned_docs/version-1.0/hello.md` updates `http://localhost:3000/docs/hello`
  38. - `docs/hello.md` updates `http://localhost:3000/docs/next/hello`