How to Set Up Documentation Publishing¶
Nothing is published until the repository is on GitHub, the site's URL is known, and the first release is tagged. Do these steps once, in this order. The examples use https://<user>.github.io/wgpathd/ as the site's URL and 0.1.0 as the first release.
Prerequisites¶
- A GitHub repository for wgpathd, with admin rights to change its Pages settings.
- The first release,
0.1.0, is ready onmain:PKG_VERSION:=0.1.0inopenwrt/wgpathd/Makefile.
1. Push main¶
git remote add origin git@github.com:<user>/wgpathd.git
git push -u origin main
2. Set the site's URL and pin the links¶
-
In
mkdocs.yml, setsite_urlto the site's base URL, without a version:site_url: https://<user>.github.io/wgpathd/ -
In
openwrt/wgpathd/Makefile, pointURL:=to the docs of the package's minor:URL:=https://<user>.github.io/wgpathd/0.1/ -
Link the README to
https://<user>.github.io/wgpathd/latest/. -
Check the pinned links:
make lint
Commit the change and push it to main. Which link goes where is in Links to the documentation.
3. Tag the first release¶
git tag v0.1.0
git push origin v0.1.0
The docs workflow creates gh-pages and publishes /0.1/ and /latest/. Wait for its publish job to succeed.
4. Turn on GitHub Pages¶
In the repository's Settings → Pages, set the source to Deploy from a branch, branch gh-pages, folder / (root). The site then answers at https://<user>.github.io/wgpathd/, which redirects to /latest/.
5. Create the docs branch¶
git branch docs/0.1 v0.1.0
git push origin docs/0.1
Doc fixes for 0.1 go through this branch: see How to fix the docs of the released version.
Clear an unversioned deploy from gh-pages¶
If gh-pages carries files from an earlier unversioned deploy, for example from mkdocs gh-deploy, remove them once: they shadow the 404 redirect and keep serving stale pages. Do it while no docs workflow is running.
-
Check out
gh-pagesand list its root:git fetch origin gh-pages git switch gh-pages git ls-tree --name-only HEAD -
Remove everything that is not part of the versioned layout: the version folders,
latest,versions.json,index.html,404.htmland.nojekyllstay.git ls-tree --name-only HEAD | grep -vxE '[0-9]+\.[0-9]+|latest|versions\.json|index\.html|404\.html|\.nojekyll' | xargs git rm -r -q git commit -m 'Remove the unversioned site' git push origin gh-pages git switch main
If gh-pages has not been published with mike yet, publish first (step 3), so that index.html is mike's redirect and not the old site's home page.