Published on: 2025-03-14
How This Site was Built
Estimated time to read: 2 minutes
This site uses Material for MkDocs and Github Pages.
Material for MkDocs is a documentation framework that sits on to of MkDocs. It allows documentation to be written in Markdown, which is then presented in a professional way.
Github Pages allows the hosting of static content sites from a GitHub on Github. This is a free service.
By using these two products, it's possible to implement "documentation-as-code" in a relatively easy to use fashion that presents well-formatted documentation.
Setup
Github Repository
-
Go to Github and create a new repository
-
Clone the repository to your local system
Installing Material for MkDocs
- Install Python
- Install pip
- Install Material for MkDocs using pip:
pip install mkdocs-material - In the directory containing the cloned repository, run the command to create a new MkDocs project:
mkdocs new . - Update the mkdocs.yml file, adding the site name, URL and the theme settings
- At this point, it's possible to run the development server and view the site locally:
mkdocs serve
Publishing with GitHub Actions
- In the repository, create a workflow file. This workflow will run on any commits pushed to the main or master branch, running the command to deploy the site. The site contents will be published to a separate branch called
gh-pages.github/workflows/ci.ymlname: ci on: push: branches: - master - main permissions: contents: write jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Configure Git Credentials run: | git config user.name github-actions[bot] git config user.email 41898282+github-actions[bot]@users.noreply.github.com - uses: actions/setup-python@v5 with: python-version: 3.x - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - uses: actions/cache@v4 with: key: mkdocs-material-${{ env.cache_id }} path: .cache restore-keys: | mkdocs-material- - run: pip install mkdocs-material - run: mkdocs gh-deploy --force - Commit the workflow file and any others to the repository
- Navigate to the Actions tab on the repository to confirm the workflow is running and completes successfully
- After the workflow completes, the 2nd branch
gh-pagesshould be visible - Navigate to the Repository settings
- Click on Pages
- Set the branch to
gh-pagesand click Save - Enter the custom domain for the site and click Save
- Go to the DNS provider for the custom domain and add a CNAME record for the custom domain that points to
<user>.github.io - Go back to the Pages section for the repository. It should regularly perform a DNS check. Once that passes, it will start provisioning a TLS certificate.
Info
The certificate provisioning process can take up to 15 minutes
- Once the certificate has been provisioned, click the Enforce HTTP checkbox so the site is accessable in a secure fashion