Skip to content

Instantly share code, notes, and snippets.

@prvn-pa
Last active May 3, 2024 22:19
Show Gist options
  • Select an option

  • Save prvn-pa/22872cd1fc652ee48f06e29f9c87c106 to your computer and use it in GitHub Desktop.

Select an option

Save prvn-pa/22872cd1fc652ee48f06e29f9c87c106 to your computer and use it in GitHub Desktop.
Steps to create a documentation site using mkdocs

How to create a documentation page using mkdocs and github pages?

Note: When trying to install using pip would leads to environment error. Avoid it using, sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.old .

  1. Installation:
    • use pip install mkdocs to install the package
  2. Create a project:
    • use mkdocs new project-name
    • then cd projec-name
    • it is better to first create a github repository gh repo create user-name/project-name
    • then gh repo clone user-name/project-name
  3. Adding files:
    • index.md carry the title page.
    • add additional files like 01_name.md, 02_name.md to create chronological order of pages.
    • this should automatically populates the side contents bar.
  4. Serving:
    • use mkdocs serve to view the site (localhost)
    • use mkdocs build for building the site
    • don't forgot to add echo "site/" >> .gitignore to ignore the build files
  5. Deploying
    • use mkdocs gh-deploy to deploy as the gh-page site
    • You should never edit files in your pages repository by hand if you're using the gh-deploy command because you will lose your work the next time you run the command.
  6. Theming
    • install material theme using pip install material-mkdocs.
    • detailed options and documentation is available here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment