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 .
- Installation:
- use
pip install mkdocsto install the package
- use
- 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
- use
- Adding files:
index.mdcarry the title page.- add additional files like
01_name.md,02_name.mdto create chronological order of pages. - this should automatically populates the side contents bar.
- Serving:
- use
mkdocs serveto view the site (localhost) - use
mkdocs buildfor building the site - don't forgot to add
echo "site/" >> .gitignoreto ignore the build files
- use
- Deploying
- use
mkdocs gh-deployto deploy as the gh-page site - You should never edit files in your pages repository by hand if you're using the
gh-deploycommand because you will lose your work the next time you run the command.
- use
- Theming
- install
materialtheme usingpip install material-mkdocs. - detailed options and documentation is available here.
- install