Writing documentation
Your documentation is a set of Markdown files in the docs/ folder. Every .md file becomes one page of the website. This page shows how to add pages, organise them and use the extras that are already switched on in your repository.
Everything in docs/ is public
Do not write down names, quotes or photos of people who did not agree to it, and do not paste API keys into examples. See What not to publish.
Add a page
- Create a file in
docs/that ends in.md, for exampledocs/how-it-fits-together.md. - Start it with one title, using a single
#. This title is shown in the navigation. - Write the rest in Markdown, using
##and###for sections.
1 2 3 4 5 6 7 | |
Save the file and it appears in the navigation of your local preview. Push it and it appears on the website.
Use lowercase file names without spaces (my-page.md, not My Page.md). The file name becomes part of the web address.
Organise your pages
A folder in docs/ becomes a section in the navigation. A file called index.md in that folder becomes the front page of that section.
Choose a structure that follows your work, not the calendar. For a repository in which several people each build something, such as a learning group repository, one folder per application plus the shared pages works well:
1 2 3 4 5 6 7 8 9 10 11 | |
The apps/ folder is explained in Publishing your application.
Set the order and the titles
By default, pages are sorted alphabetically. To decide the order yourself, put a file called .pages in the folder:
| docs/.pages | |
|---|---|
1 2 3 4 5 6 | |
- Each line is a file or a folder in that same folder.
Some title: file.mdgives the page a different title in the navigation....means "everything I did not mention". Leave it out and the pages you did not list disappear from the navigation.
To rename a folder in the navigation, put a .pages file inside that folder:
| docs/sign-language-explainer/.pages | |
|---|---|
1 2 3 4 | |
Indentation matters
.pages files are YAML. Indent with spaces, not tabs, and keep the lines under nav: lined up exactly. A misaligned line breaks the build.
Links and images
Always link relative to the file you are writing in, and link to the .md file, not to a web address. MkDocs converts it for you.
| You are in | You want to link to | Write |
|---|---|---|
docs/index.md |
docs/gesture-game/index.md |
[Gesture game](gesture-game/index.md) |
docs/gesture-game/index.md |
docs/gesture-game/iterations.md |
[Iterations](iterations.md) |
docs/gesture-game/iterations.md |
docs/gesture-game/index.md |
[Gesture game](./index.md) |
docs/gesture-game/iterations.md |
docs/index.md |
[Home](../index.md) |
.. means "one folder up". Never start a link with /: it can work in the local preview and break on the published website. Because your site has several files called index.md, write ./index.md when you link to the one in the same folder.
Images work the same way. Put them in a folder next to the page and link to them relatively:
1 | |
The text between the square brackets is read aloud by screen readers and shown when the image fails to load, so describe what is in the picture. Add { width="400" } directly after the closing bracket to set a size.
What you can use
These extras are already switched on in your repository.
Call-outs
1 2 3 4 5 | |
The text must be indented with four spaces. Useful types are note, tip, warning, danger, example and quote. Replace !!! with ??? to make the call-out collapsible, which is handy for long logs or code.
Code
1 2 3 4 | |
Name the language after the three backticks to get syntax highlighting.
Diagrams
A code block with the language mermaid is drawn as a diagram:
1 2 3 4 | |
See the Mermaid documentation for flowcharts, sequence diagrams and more. Diagrams are a good way to show how your system works.
Checklists
1 2 | |
Video
Short screen recordings are a good way to document an iteration that no longer exists. Put the file next to your page and write:
1 | |
Keep videos short and small. Large files make the repository slow for everyone in your team. For longer recordings, upload the video elsewhere and link to it.
HTML and JavaScript
You can write HTML directly in a Markdown file, including <script> tags. The example page linear-regression-explorer.md in your repository does this. For anything bigger than a small demo, give your application its own folder, as described in Publishing your application.
Document your iterations
Good documentation shows how the work came to be, not only the end result. In a learning group this is required: your documentation must show how the application came to be, including the iterations. A structure that works well is one section per iteration:
1 2 3 4 5 6 7 8 9 10 11 | |
Write it in the week it happens. Screenshots and recordings of earlier versions are impossible to recreate afterwards.
Checklist
- Every page starts with one
#title. - My links are relative and point to
.mdfiles. - My images have a description.
- The local preview shows no warnings.
- The example pages of the template are removed.
- There is nothing on my pages that should not be public.