How to publish Markdown docs as a website
If your documentation already lives as Markdown files in a repository, you can publish it as a website with free tools. This guide walks through the manual route with MkDocs and GitHub Pages, then lists what to maintain so the site does not go stale.
Start with a clean folder of Markdown
A docs site is only as good as its source. Put your pages in one folder, give each page a clear first heading, and use an index page for the landing page. MkDocs, a free static site generator, expects exactly this: a configuration file next to a docs folder that starts with one index page.
Decide the page order before you build. In MkDocs the nav setting in the configuration file controls the order, titles and nesting of pages, so you can keep file names short and still show friendly titles. Plan the top level of the navigation first, with no more than six or seven entries, and let each section hold its own pages.
- One topic per page, with a short first paragraph that says what the page covers.
- Folders that match how a reader thinks (Getting started, Guides, Reference).
- Relative links between pages, so the links survive a move.
- Images in one folder, with short descriptions.
Build and preview on your own computer
MkDocs installs through Python's pip. Its getting-started guide has you create a project, add Markdown files to the docs folder and run the built-in preview server, which rebuilds when you change a file. Search works out of the box and indexes all pages. The only required setting is the site name.
Preview every page before you publish. Click each link, check the navigation order and read the search results for a few common questions. MkDocs can also build the finished site into a site folder, which is the folder you publish. Keep that folder out of your repository, as the MkDocs guide advises, so built files are not committed by accident. If a search for a term your readers use finds nothing, add that term to the page title or first paragraph.
Choose where the site lives
MkDocs builds plain static HTML into a site folder. You can copy that folder to any static web host. The MkDocs deployment guide also describes a one-step deploy to GitHub Pages that pushes the built site to a separate branch, and notes that you should not hand-edit that pages branch because changes are lost on the next deploy.
GitHub's own quickstart for Pages has you open the repository Settings, select Pages, and under Build and deployment choose Deploy from a branch. It says changes can take up to 10 minutes to appear. The MkDocs guide also warns that untracked or uncommitted files in your source folder are included in the deployed site, so check what is in the folder before you publish. For a public project, it names Read the Docs as another place that hosts MkDocs projects for free and rebuilds them on each push when configured.
Use your own domain
Readers trust a docs address that matches your product. The MkDocs deployment guide says that for GitHub Pages you add a CNAME file containing your domain to the docs folder, otherwise the setting can be dropped on the next deploy. Use a subdomain such as docs.yourcompany.com for the docs.
After you add the DNS record, open the site by its new address and check that the certificate loads without a warning. DNS changes can take a while to spread, so test again later in the day before you tell anyone the new address.
Keep the docs current
The hard part is not the first publish. It is keeping the site in step with the product. Without a routine, the manual route tends to leave an old build online, and readers find answers for a version you no longer ship. Every manual step you add is one more that someone has to remember, so write the routine down and keep it short. A one-page checklist that lives next to the docs is enough.
- Rebuild and publish on every release, not only when someone remembers.
- Keep an older copy of the docs for each supported version, and label it.
- Test links after every restructure.
- Name one person who owns the docs and a day each month to review them.
- Add a line to your release checklist: docs updated, docs published.
- Read the site on a phone once, since many readers will arrive from a search on one.
Where DocsPier fits
DocsPier is coming soon and is meant to do the building and hosting part of this for you: it builds a searchable site from your repository or a zip file, keeps versions and, on the Pro plan, serves it on your own domain. We have not set a launch date, and the manual route above works today.
Sources
Coming soon: DocsPier
A docs website built from your Markdown, at one flat price. DocsPier turns a repository on GitHub, Azure DevOps or GitLab (or a zip file) full of Markdown into a searchable documentation website. It keeps versions of your docs, and the Pro plan serves them on your own domain. It is for software teams who want docs online without running a docs server or paying per editor.
Get DocsPier first
Join the list and get 25% off your first purchase when it goes on sale. We email you a discount code on launch day. One code per person, for new customers.
One email when it launches (plus the discount code). No other mail, and you can say stop at any time. See our privacy policy.