This guide explains how to set up automatic deployment of MkDocs documentation to GitHub Pages.
The documentation is automatically built and deployed on every push to the main or master branch.
-
Enable GitHub Pages:
- Go to your repository on GitHub
- Navigate to Settings → Pages
- Under Source, select GitHub Actions
- Save the changes
-
Push to trigger deployment:
git push origin main
-
Verify deployment:
- Go to Actions tab in your repository
- You should see "Deploy Documentation" workflow running
- Once complete, your docs will be available at:
https://your-username.github.io/tradingbot25/
You can also trigger deployment manually:
- Go to Actions tab
- Select Deploy Documentation workflow
- Click Run workflow
- Select branch and click Run workflow
The GitHub Actions workflow (.github/workflows/docs.yml) does the following:
- Checks out the repository
- Sets up Python 3.12 and
uv - Installs dependencies including MkDocs and plugins
- Builds documentation using
mkdocs build - Deploys to GitHub Pages automatically
-
Check GitHub Pages settings:
- Ensure "GitHub Actions" is selected as the source
- Check that the workflow has completed successfully
-
Check workflow logs:
- Go to Actions tab
- Click on the latest workflow run
- Review logs for any errors
-
Common issues:
- Build failures: Check that all dependencies are in
pyproject.tomlunder[project.optional-dependencies.docs] - Import errors: Ensure
tradingbotmodule can be imported (check Python path) - Missing files: Verify all markdown files referenced in
mkdocs.ymlexist
- Build failures: Check that all dependencies are in
If your repository URL changes, update mkdocs.yml:
repo_name: tradingbot25
repo_url: https://github.com/your-username/tradingbot25Before pushing, test the build locally:
# Install dependencies
uv sync --extra docs
# Build documentation
uv run mkdocs build
# Check for errors
# Output should be in ./site directoryTo use a custom domain:
-
Add a
CNAMEfile todocs/directory:docs.yourdomain.com -
Configure DNS:
- Add a CNAME record pointing to
your-username.github.io
- Add a CNAME record pointing to
-
Update GitHub Pages settings:
- Go to Settings → Pages
- Enter your custom domain