On this page
Domains and previews#
Your own domain#
- Add a DNS record with your domain provider. For a subdomain such as
docs.example.com, aCNAMErecord pointing to the host:<user>.github.iofor GitHub Pages, the*.pages.devaddress for Cloudflare Pages, or the*.netlify.appaddress for Netlify. For an apex domain such asexample.com, follow the host's guide: GitHub, Cloudflare, Netlify. - Enter the domain in the host's settings. On GitHub, that is Settings → Pages → Custom domain; turn on Enforce HTTPS once the certificate is ready.
- Set
site_urlto the new address:
site_url: https://docs.example.com/
site_url is where the sitemap, the feed, llms.txt, social previews and canonical links point. Without it, they are missing or incomplete.
Note
With mkdocs gh-deploy, GitHub reads the domain from a CNAME file in the published branch. Put a file named CNAME holding the domain in docs/, and every build copies it along. A GitHub Actions deployment does not need the file.
Moving to a new domain#
Readers and search engines still have the old links. Most hosts can redirect a whole domain: keep the old domain attached and add a redirect rule to the new one, path included. For moved pages inside one site, the mkdocs-redirects plugin writes small pages that forward to the new address.
Preview before publishing#
mkdocs serve rebuilds on every save and reloads the browser. If a page looks different from a full build, mkdocs serve --clean turns off the preview server's caches.mkdocs build and then python -m http.server -d site, to see the real output. Opening site/index.html from the file system is not enough: browsers block search and fonts on file:// pages.--strict, which catches broken links. To browse a preview, check out the branch and build it locally, or let Cloudflare or Netlify deploy previews.Search engines should not index previews. Preview hosts usually add an X-Robots-Tag: noindex header to preview addresses; check yours if previews show up in search results.
Several versions#
To keep the documentation of older releases online, publish each version to its own folder with mike. Sumi then shows a version menu in the header and a notice on old versions. See Navigation.
Several languages#
A translated site is one build: each language is written to its own folder, such as /zh/. See Languages. Nothing changes for deployment.