|
| 1 | +Markdoc |
| 2 | +======= |
| 3 | + |
| 4 | +.. meta:: |
| 5 | + :description lang=en: Hosting Markdoc documentation on Read the Docs. |
| 6 | + |
| 7 | +`Markdoc`_ is a powerful documentation framework that allows you to write documentation in a flavor of Markdown. |
| 8 | + |
| 9 | +Minimal configuration is required to build an existing Markdoc project on Read the Docs. |
| 10 | + |
| 11 | +.. code-block:: yaml |
| 12 | + :caption: .readthedocs.yaml |
| 13 | +
|
| 14 | + version: 2 |
| 15 | +
|
| 16 | + build: |
| 17 | + os: ubuntu-24.04 |
| 18 | + tools: |
| 19 | + nodejs: "22" |
| 20 | + commands: |
| 21 | + # Install dependencies |
| 22 | + - cd docs/ && npm install |
| 23 | + # Build the site |
| 24 | + - cd docs/ && npm run build |
| 25 | + # Copy generated files into Read the Docs directory |
| 26 | + - mkdir --parents $READTHEDOCS_OUTPUT/html/ |
| 27 | + - cp --verbose --recursive docs/out/* $READTHEDOCS_OUTPUT/html/ |
| 28 | +
|
| 29 | +.. _Markdoc: https://markdoc.io/ |
| 30 | + |
| 31 | +Example configuration |
| 32 | +--------------------- |
| 33 | + |
| 34 | +In order to build a Markdoc project on Read the Docs, |
| 35 | +you need to generate static HTML from the Next JS build: |
| 36 | + |
| 37 | +.. code-block:: js |
| 38 | + :caption: next.config.js |
| 39 | +
|
| 40 | + const withMarkdoc = require('@markdoc/next.js'); |
| 41 | +
|
| 42 | + const nextConfig = { |
| 43 | + // Optional: Export HTML files instead of a Node.js server |
| 44 | + output: 'export', |
| 45 | +
|
| 46 | + // Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html` |
| 47 | + trailingSlash: true, |
| 48 | +
|
| 49 | + // Use Canonical URL, but only the path and with no trailing / |
| 50 | + // End result is like: `/en/latest` |
| 51 | + basePath: process.env.READTHEDOCS_CANONICAL_URL |
| 52 | + ? new URL(process.env.READTHEDOCS_CANONICAL_URL).pathname.replace(/\/$/, "") |
| 53 | + : "", |
| 54 | + } |
| 55 | +
|
| 56 | + module.exports = |
| 57 | + withMarkdoc({mode: 'static'})({ |
| 58 | + pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdoc'], |
| 59 | + ...nextConfig, |
| 60 | + }); |
| 61 | +
|
| 62 | +Supported features |
| 63 | +------------------ |
| 64 | + |
| 65 | +.. csv-table:: Supported features |
| 66 | + :header: "Feature", "Description", "Supported" |
| 67 | + |
| 68 | + "Pull request previews", "Preview changes to your documentation before merging.", "✅" |
| 69 | + "Versioning", "Supports multiple versions of your documentation.", "✅" |
| 70 | + "Search", "Provides full-text search capabilities.", "✅" |
| 71 | + "Flyout menu", "Provides a flyout menu for navigation.", "✅" |
| 72 | + "Offline formats", "Generates PDF and EPUB formats.", "✅" |
| 73 | + "Localization", "Supports multiple languages.", "✅" |
| 74 | + |
| 75 | +Getting started |
| 76 | +--------------- |
| 77 | + |
| 78 | +- If you have an existing Markdoc project you want to host on Read the Docs, check out our :doc:`/intro/add-project` guide. |
| 79 | +- If you're new to Markdoc, check out the official `Getting started with Markdoc`_ guide. |
| 80 | + |
| 81 | +.. _Getting started with Markdoc: https://markdoc.io/docs/getting-started |
| 82 | + |
| 83 | +Example repository and demo |
| 84 | +--------------------------- |
| 85 | + |
| 86 | +Example repository |
| 87 | + https://github.com/readthedocs/test-builds/tree/markdoc |
| 88 | + |
| 89 | +Demo |
| 90 | + https://test-builds.readthedocs.io/en/markdoc/ |
| 91 | + |
| 92 | +Further reading |
| 93 | +--------------- |
| 94 | + |
| 95 | +* `Markdoc documentation`_ |
| 96 | + |
| 97 | +.. _Markdoc documentation: https://markdoc.io/docs |
0 commit comments