|
| 1 | + |
| 2 | +Docusarus |
| 3 | +========= |
| 4 | + |
| 5 | +.. meta:: |
| 6 | + :description lang=en: Hosting Docusaurus sites on Read the Docs. |
| 7 | + |
| 8 | +`Docusaurus`_ is a static-site generator that builds a single-page application with fast client-side navigation and out-of-the-box documentation features. |
| 9 | + |
| 10 | +Minimal configuration required to build a Docusaurus project on Read the Docs looks like this, |
| 11 | +specifying a nodejs toolchain on Ubuntu, using multiple :ref:`build <config-file/v2:build>` commands to install the requirements, |
| 12 | +build the site, and copy the output to $READTHEDOCS_OUTPUT: |
| 13 | + |
| 14 | +.. code-block:: yaml |
| 15 | + :caption: .readthedocs.yaml |
| 16 | +
|
| 17 | + version: 2 |
| 18 | + build: |
| 19 | + os: "ubuntu-22.04" |
| 20 | + tools: |
| 21 | + nodejs: "18" |
| 22 | + commands: |
| 23 | + # "docs/" was created following the Docusaurus tutorial: |
| 24 | + # npx create-docusaurus@latest docs classic |
| 25 | + # but you can just use your existing Docusaurus site |
| 26 | + # |
| 27 | + # Install Docusaurus dependencies |
| 28 | + - cd docs/ && npm install |
| 29 | + # Build the site |
| 30 | + - cd docs/ && npm run build |
| 31 | + # Copy generated files into Read the Docs directory |
| 32 | + - mkdir --parents $READTHEDOCS_OUTPUT/html/ |
| 33 | + - cp --recursive docs/build/* $READTHEDOCS_OUTPUT/html/ |
| 34 | +
|
| 35 | +.. _Docusaurus: https://docusaurus.io/ |
| 36 | + |
| 37 | +Limitations |
| 38 | +----------- |
| 39 | + |
| 40 | +.. csv-table:: Limitations |
| 41 | + :header: "Feature", "Description", "Supported" |
| 42 | + |
| 43 | + "Search", "Provides full-text search capabilities.", "Not supported" |
| 44 | + "Files changed", "Ability to see what HTML files changes in pull request previews", "Not supported" |
| 45 | + |
| 46 | + |
| 47 | +Quick start |
| 48 | +----------- |
| 49 | + |
| 50 | +- If you have an existing Docusaurus project you want to host on Read the Docs, check out our :doc:`/intro/add-project` guide. |
| 51 | + |
| 52 | +- If you're new to Docusaurus, check out the official `Fast Track`_ guide. |
| 53 | + |
| 54 | +.. _Fast Track: https://docusaurus.io/docs#fast-track |
| 55 | + |
| 56 | +Configuring Docusaurus and Read the Docs addons |
| 57 | +----------------------------------------------- |
| 58 | + |
| 59 | +For optimal integration with Read the Docs, make the optional following configuration changes to your Docusaurus config. |
| 60 | + |
| 61 | +.. contents:: |
| 62 | + :depth: 1 |
| 63 | + :local: |
| 64 | + :backlinks: none |
| 65 | + |
| 66 | +Set the canonical URL |
| 67 | +~~~~~~~~~~~~~~~~~~~~~ |
| 68 | + |
| 69 | +A :doc:`canonical URL </canonical-urls>` allows you to specify the preferred version of a web page |
| 70 | +to prevent duplicated content. |
| 71 | + |
| 72 | +Set your Docusaurus `url`_ to your Read the Docs canonical URL using `dotenv <https://www.npmjs.com/package/dotenv>`__ and a |
| 73 | +:doc:`Read the Docs environment variable </reference/environment-variables>`: |
| 74 | + |
| 75 | +.. code-block:: js |
| 76 | + :caption: docusaurus.config.js |
| 77 | +
|
| 78 | + import 'dotenv/config'; |
| 79 | +
|
| 80 | + export default { |
| 81 | + url: process.env.READTHEDOCS_CANONICAL_URL, |
| 82 | + }; |
| 83 | +
|
| 84 | +.. _url: https://docusaurus.io/docs/configuration#syntax-to-declare-docusaurus-config |
| 85 | + |
| 86 | +Example repository and demo |
| 87 | +--------------------------- |
| 88 | + |
| 89 | +Example repository |
| 90 | + https://github.com/readthedocs/test-builds/tree/docusaurus |
| 91 | + |
| 92 | +Demo |
| 93 | + https://test-builds.readthedocs.io/en/docusaurus/ |
0 commit comments