mirror of
https://github.com/MichaelCurrin/mkdocs-quickstart.git
synced 2026-03-28 17:42:47 +01:00
Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a028e5c228 | ||
|
|
49d6ee84a7 | ||
|
|
f21ac0fe3c | ||
|
|
3b5f31d73d | ||
|
|
3a743ae48f | ||
|
|
fdbbb73cd6 | ||
|
|
953967dda8 | ||
|
|
35ce122bd8 | ||
|
|
89fbc16c26 | ||
|
|
e7800bc936 | ||
|
|
54be3ff415 | ||
|
|
b48560c99d | ||
|
|
d14aca853a | ||
|
|
11c1377a9f | ||
|
|
5e8b217c8d | ||
|
|
b842ce958e | ||
|
|
787dc334a1 | ||
|
|
286e8c6f0d | ||
|
|
1decccd809 | ||
|
|
6bef7960f0 | ||
|
|
645a052e22 | ||
|
|
da67a34443 | ||
|
|
4a9f27222a | ||
|
|
8feabd1a43 | ||
|
|
ae37b3874d | ||
|
|
3630bab42c | ||
|
|
4726a67ef3 | ||
|
|
c25398473f | ||
|
|
b27fe05ebe | ||
|
|
01e7c407b0 | ||
|
|
8434d546bb | ||
|
|
4753edcbe9 | ||
|
|
7e69b48377 | ||
|
|
6a5cfe2377 | ||
|
|
7177e48983 | ||
|
|
989e13de5e | ||
|
|
4c169b9981 | ||
|
|
81e9147b2b | ||
|
|
6f7122d7cd | ||
|
|
f537e68f5f | ||
|
|
49b3a80578 | ||
|
|
dbc5a5a15e | ||
|
|
bcd5d97980 | ||
|
|
bf0b822e71 | ||
|
|
1743e1c99f | ||
|
|
a4858ef9ef | ||
|
|
24fcac8f5b | ||
|
|
aa732678ba | ||
|
|
66f0fa8cd7 | ||
|
|
eebbe99358 | ||
|
|
0f4f91bbc8 | ||
|
|
bbdbd30f69 | ||
|
|
09f8bc898f | ||
|
|
8aa74eb6b0 | ||
|
|
9571f1ad46 | ||
|
|
91582e3392 | ||
|
|
b4f9479472 | ||
|
|
7b0ffe8c9d | ||
|
|
a8d346de5d | ||
|
|
aa4bf1088c | ||
|
|
84b65458a2 | ||
|
|
f4f6a6861d | ||
|
|
735ab35a26 | ||
|
|
65d7c7343b | ||
|
|
0ae70d2fcd | ||
|
|
7b729ba759 | ||
|
|
e0d9117274 | ||
|
|
928f697e0c | ||
|
|
f45d546ccf | ||
|
|
3400d5c4bb | ||
|
|
95f5e64589 | ||
|
|
1b92ee3dde | ||
|
|
d2521f69a4 | ||
|
|
e14b88702e | ||
|
|
10bb3fabcc | ||
|
|
ddb2e02ac0 | ||
|
|
9a4668db47 | ||
|
|
375db30200 | ||
|
|
15e528c07f | ||
|
|
b61b9d1a70 | ||
|
|
2d5113a961 | ||
|
|
2b4544320b | ||
|
|
52a8f7862a | ||
|
|
bdcd8f367c | ||
|
|
cfb5853123 | ||
|
|
d59ed88866 | ||
|
|
7e5650e241 | ||
|
|
dc05d52b62 | ||
|
|
3e735f3893 | ||
|
|
7a07748602 | ||
|
|
06171073a3 | ||
|
|
0b9cc10056 | ||
|
|
29f21df22c | ||
|
|
4f2c416522 |
23
.github/workflows/docs.yml
vendored
Normal file
23
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Deploy docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: make install
|
||||
|
||||
- name: Build and deploy
|
||||
run: make deploy
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.pythonPath": "venv/bin/python"
|
||||
}
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 michaelcurrin
|
||||
Copyright (c) 2020 MichaelCurrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
22
Makefile
Normal file
22
Makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
.PHONY: docs
|
||||
|
||||
default: install
|
||||
|
||||
|
||||
h help:
|
||||
@egrep '(^\S)|(^$$)|\s+@echo' Makefile
|
||||
|
||||
|
||||
install:
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
|
||||
s serve:
|
||||
mkdocs serve --strict
|
||||
|
||||
b build:
|
||||
mkdocs build --strict
|
||||
|
||||
d deploy:
|
||||
mkdocs gh-deploy --strict --force
|
||||
88
README.md
88
README.md
@@ -1,2 +1,88 @@
|
||||
# MkDocs Quickstart
|
||||
> A brief guide for setting up a MkDocs docs site on Github Pages
|
||||
> A template, live demo and tutorial for how to setup a MkDocs docs site on GitHub Pages
|
||||
|
||||
[](https://github.com/MichaelCurrin/mkdocs-quickstart/actions)
|
||||
[](https://www.mkdocs.org/)
|
||||
[](https://github.com/features/actions)
|
||||
[](https://github.com/mhausenblas/mkdocs-deploy-gh-pages)
|
||||
[](https://GitHub.com/MichaelCurrin/mkdocs-quickstart/tags/)
|
||||
[](#license)
|
||||
|
||||
|
||||
<!-- TODO When creating a new project copied from this template, you can delete this README.md and start over -->
|
||||
|
||||
## Purpose
|
||||
|
||||
A low-code way to setup and host a markdown-based docs site with a professional look.
|
||||
|
||||
|
||||
## Preview
|
||||
|
||||
[](https://michaelcurrin.github.io/mkdocs-quickstart/)
|
||||
|
||||
This project uses the _Read the Docs_ theme as seen above. It comes with MkDocs so you don't need to add to your dependencies. But you can switch to the MkDocs default or install and configure another theme.
|
||||
|
||||
|
||||
## How to use this project
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://michaelcurrin.github.io/mkdocs-quickstart/)
|
||||
[](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- A markdown-based docs site which is easy to edit - see the content [docs](/docs/) directory.
|
||||
- Easy to configure - see the short [mkdocs.yml](/mkdocs.yml) file.
|
||||
- Use the configured theme or switch to another - no need to write HTML and CSS yourself.
|
||||
- Each theme comes with a navbar and you write YAML - Jekyll themes on GH Pages need you to write your own HTML often and each theme handles navbar its own way (sometimes not at all).
|
||||
- Uses a deploy pipeline on GH Actions to deploy a GH Pages site - the action actually runs GH Pages deploy command.
|
||||
- The static site output is SEO-friendly.
|
||||
- Built on Python but you don't need to write any Python code.
|
||||
|
||||
### View live demo site
|
||||
|
||||
This project has a site deployed to GitHub Pages.
|
||||
|
||||
Purposes of the site:
|
||||
|
||||
- A live demo.
|
||||
- Content for a beginner-friendly tutorial on how to setup, run, deploy and customize a MkDocs project like this one.
|
||||
|
||||
### Use this template
|
||||
|
||||
This repo also doubles as a template to create a new project from. Click the button at the top.
|
||||
|
||||
Change the content and theme to suit your needs, based on the tutorial site or the MkDocs site.
|
||||
|
||||
To isolate the MkDocs flow from the rest of your code, you can put the configs and the `docs` folder of content inside the `docs` directory. That means you end up having `docs/docs`, which is okay. Just make sure you select the `/docs` directory when setting up GH Pages.
|
||||
|
||||
|
||||
## Why use MkDocs?
|
||||
|
||||
If you're new to MkDocs, look at the tutorial added on this project's site, otherwise go to the MkDocs documentation.
|
||||
|
||||
This project provides a way to write your docs in markdown and build a professional-looking docs site on top of it, without having to write HTML or CSS code and using a selection of themes. While MkDocs CLI has functionality to deploy from a local command-line, this project makes deploying effortless by using GitHub Actions to build and deploy the site to a `gh-pages` branch and GitHub Pages to serve the site.
|
||||
|
||||
Compared with Jekyll and Docsify, I found the MkDocs code is much lighter to setup and changing themes is much easier than Jekyll. Also you get the benefits SEO which Docsify doesn't have. And it includes a search bar using JS.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Submit an issue.
|
||||
|
||||
Or submit a code change:
|
||||
|
||||
1. Fork this project.
|
||||
2. Set up the project locally - follow the instructions on the live tutorial or in the [TLDR](/docs/tutorial/tldr.md) page of the local docs.
|
||||
3. Make any changes you want. Be sure to keep a copy of the original license in the repo.
|
||||
- e.g. `cp LICENSE LICENSE-source`
|
||||
4. Create a Pull Request.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Released under [MIT](/LICENSE).
|
||||
|
||||
40
docs/about-mkdocs.md
Normal file
40
docs/about-mkdocs.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# About MkDocs
|
||||
|
||||
|
||||
## What is MkDocs?
|
||||
|
||||
The description on the MkDocs site is:
|
||||
|
||||
> Project documentation with Markdown.
|
||||
|
||||
MkDocs is a Python tool that generates a static site based on content written in Markdown.
|
||||
|
||||
If you are new to markdown, see the [Getting Started](https://www.markdownguide.org/getting-started/) page on the Markdown Guide website.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- [mkdocs.org](https://www.mkdocs.org) homepage
|
||||
- [mkdocs/mkdocs ](https://github.com/mkdocs/mkdocs)
|
||||
- [MkDocs Wiki](https://github.com/mkdocs/mkdocs/wiki) - covering themes, plugins, recipes and more.
|
||||
|
||||
|
||||
## Reasons to use MkDocs
|
||||
|
||||
- Create an elegant, modern docs site for your project.
|
||||
- Create a static site and serve from GitHub Pages easily.
|
||||
- Low-code solution
|
||||
- No need to write HTML or learn templating syntax needed
|
||||
- Use your existing markdown files as content.
|
||||
- Configure with a simple YAML file.
|
||||
- Customizable.
|
||||
- Add custom HTML if you want.
|
||||
- Plugins available.
|
||||
- Flexible theme choices.
|
||||
- Includes search by default.
|
||||
- Broken links to files (including from your navbar) will be detected at build time and shown as warnings.
|
||||
|
||||
|
||||
## Do I need to know Python?
|
||||
|
||||
MkDocs is built in Python (like Sphinx), but you don't have to write Python code. If you setup a [Deploy](deploy) flow right, you don't even have to set it up locally, though then you can't preview.
|
||||
@@ -1,31 +0,0 @@
|
||||
# Deploy
|
||||
> How to deploy a MkDocs site
|
||||
|
||||
|
||||
See [Deploying Your Docs](https://www.mkdocs.org/user-guide/deploying-your-docs/) on the Mkdocs site for more details.
|
||||
|
||||
|
||||
## Github Pages
|
||||
|
||||
_Note this is for a Project Page and not Organization and User Pages._
|
||||
|
||||
How to deploy to Github Pages.
|
||||
|
||||
Run this to build to `site` directory, push to `gh-pages` branch and enable Github Pages (if it was not yet enabled). The default option is to clean the site directory first.
|
||||
|
||||
```sh
|
||||
mkdocs gh-deploy
|
||||
```
|
||||
|
||||
Then go to your repo on Github, see the *environment* tab and click _View deployment_.
|
||||
|
||||
e.g.
|
||||
|
||||
- [michaelcurrin.github.io/mkdocs-quickstart/](https://michaelcurrin.github.io/mkdocs-quickstart/)
|
||||
|
||||
|
||||
See deploy options:
|
||||
|
||||
```sh
|
||||
mkdocs gh-deploy --help
|
||||
```
|
||||
@@ -1,5 +1,27 @@
|
||||
# MkDocs Quickstart
|
||||
> A brief guide for setting up a MkDocs docs site on Github Pages
|
||||
> A template, live demo and tutorial for how to setup a MkDocs docs site on GitHub Pages
|
||||
|
||||
[](https://github.com/MichaelCurrin/mkdocs-quickstart)
|
||||
|
||||
|
||||
This is based on the [mkdocs.org](https://www.mkdocs.org/) tutorial.
|
||||
Use the MkDocs (make docs) tool to create build a docs site around markdown docs.
|
||||
|
||||
Follow the tutorial to add an existing project or create a project from scratch. The result will look like this project.
|
||||
|
||||
|
||||
## Features
|
||||
> How to use this project
|
||||
|
||||
- **Follow the tutorial instructions**
|
||||
- Install and configure a new or existing project.
|
||||
- Run it locally.
|
||||
- Deploy it.
|
||||
- **Add a copy of this project to your repos**
|
||||
- [](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
|
||||
- **View the live demo**
|
||||
- This site is hosted on GitHub Pages. See if you like it. Other themes are available - see the tutorial.
|
||||
|
||||
|
||||
The aim here is not be complete or explain all concepts. It is to provide a reference for common steps and choices needed when setting up a docs site, but still at a beginner-friendly level.
|
||||
|
||||
This guide is based on the [mkdocs.org](https://www.mkdocs.org/) tutorial.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# Setup and run
|
||||
> How to setup and run the docs site
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
Install in a virtual environment.
|
||||
|
||||
```sh
|
||||
pip install mkdocs
|
||||
```
|
||||
|
||||
|
||||
## Server docs locally
|
||||
|
||||
This will build the docs in memory (not to disk) and serve an auto-reloading server.
|
||||
|
||||
```sh
|
||||
mkdocs serve
|
||||
```
|
||||
|
||||
Open URL:
|
||||
|
||||
- [localhost:8000](http://localhost:8000)
|
||||
|
||||
|
||||
|
||||
## Build docs
|
||||
|
||||
Build docs site to `site` directory.
|
||||
|
||||
```sh
|
||||
mkdocs build
|
||||
```
|
||||
|
||||
Useful for production build or simulating that locally.
|
||||
|
||||
|
||||
Remove stale files.
|
||||
|
||||
```sh
|
||||
mkdocs build --clean
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
# Tutorial
|
||||
> How to create a MkDocs site.
|
||||
|
||||
This is a summary of the tutorial on [mkdocs.org](https://www.mkdocs.org/).
|
||||
|
||||
|
||||
### Setup site
|
||||
|
||||
1. Create pages.
|
||||
1. Create `docs` directory.
|
||||
2. Create `index.md`
|
||||
3. Create other pages.
|
||||
2. Setup config.
|
||||
1. Create `mkdocs.yml` at project root.
|
||||
2. Setup navbar in `mkdocs.yml`.
|
||||
```yaml
|
||||
nav:
|
||||
- Home: index.md
|
||||
- About: about.md
|
||||
```
|
||||
3. Choose a theme.
|
||||
```yaml
|
||||
theme: readthedocs
|
||||
```
|
||||
3. Create a favicon.
|
||||
- It will be picked up this path: `docs/img/favicon.ico`.
|
||||
|
||||
|
||||
### Further configuration
|
||||
|
||||
See [Configuration](https://www.mkdocs.org/user-guide/configuration/) page on MkDocs site for options.
|
||||
53
docs/tutorial/advanced.md
Normal file
53
docs/tutorial/advanced.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Advanced
|
||||
> Beyond the basic configuration and content
|
||||
|
||||
Once you've got the [Setup Project](setup-project.md) section, you can customize further using this guide. Or skip this and go to [Usage](usage.md).
|
||||
|
||||
|
||||
## Navbar nesting
|
||||
|
||||
You can add an additional level to your navbar like this:
|
||||
|
||||
```yaml
|
||||
nav:
|
||||
- Home: index.md
|
||||
- About: about.md
|
||||
- Foo:
|
||||
- Overview: foo/index.md
|
||||
- Bar: foo/bar.md
|
||||
```
|
||||
|
||||
The value can either be a string (as in the first case) or a map (as in the last case). This seems to be a YAML limitation but see also [issue #1139](https://github.com/mkdocs/mkdocs/issues/1139).
|
||||
|
||||
|
||||
## Add config options
|
||||
|
||||
See [Configuration](https://www.mkdocs.org/user-guide/configuration/) page on MkDocs site for options.
|
||||
|
||||
|
||||
## Separate docs directory approach
|
||||
|
||||
You can also structure your project to have the setup above nested inside a `docs` directory. This is useful you have a few other directories and you want to keep the project root clean.
|
||||
|
||||
|
||||
- `docs/`
|
||||
- `docs/`
|
||||
- `index.md`
|
||||
- `theme/`
|
||||
- `main.html`
|
||||
- `nav.html`
|
||||
- `toc.html`
|
||||
- `mkdocs.yml`
|
||||
|
||||
|
||||
An example of this is the [Poetry](https://github.com/python-poetry/poetry/tree/master/docs) repo. That project is also how I got into MkDocs in the first place.
|
||||
|
||||
## Embedding
|
||||
|
||||
To embed a gist, just copy and paste the embed script URL which is provided on a gist.
|
||||
|
||||
e.g.
|
||||
|
||||
```html
|
||||
<script src="https://gist.github.com/MichaelCurrin/57caae30bd7b0991098e9804a9494c23.js"></script>
|
||||
```
|
||||
64
docs/tutorial/deploy.md
Normal file
64
docs/tutorial/deploy.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Deploy
|
||||
> Build and deploy to a remote public site
|
||||
|
||||
|
||||
See [Deploying Your Docs](https://www.mkdocs.org/user-guide/deploying-your-docs/) on the Mkdocs site for more details.
|
||||
|
||||
|
||||
## GitHub Pages
|
||||
> How to deploy your docs site to GitHub Pages.
|
||||
|
||||
Follow one of the approaches below:
|
||||
|
||||
- [Run deploy command](#run-deploy-command) - Run a MkDocs CLI command locally to deploy.
|
||||
- [Deploy with Githhub Actions](#deploy-with-github-actions) - Setup continous deployment config to enable deploys on a change to files on GitHub.
|
||||
|
||||
|
||||
_Note this is for a Project Page on a subpath and not an Organization or User Page._
|
||||
|
||||
### Run deploy command
|
||||
> Run a MkDocs CLI command locally to deploy
|
||||
|
||||
MkDocs needs to know where to publish commits on GitHub - so make sure you are working with a repo that you cloned, or that you initialize the local repo and add a `remote` repo.
|
||||
|
||||
Run this command locally:
|
||||
|
||||
```sh
|
||||
$ make d
|
||||
```
|
||||
|
||||
That will use `Makefile` to run the following:
|
||||
|
||||
```sh
|
||||
$ mkdocs gh-deploy --strict
|
||||
```
|
||||
|
||||
That will do the following:
|
||||
|
||||
1. Clean and build to `site` directory.
|
||||
2. Push to `gh-pages` branch. Note: You must not edit this branch directly.
|
||||
3. Enable GitHub Pages if it was not yet enabled
|
||||
|
||||
Then go to your repo on GitHub, see the *environment* tab and click _View deployment_.
|
||||
|
||||
e.g.
|
||||
|
||||
- [michaelcurrin.github.io/mkdocs-quickstart/](https://michaelcurrin.github.io/mkdocs-quickstart/)
|
||||
|
||||
|
||||
See deploy options:
|
||||
|
||||
```sh
|
||||
$ mkdocs gh-deploy --help
|
||||
```
|
||||
|
||||
### Deploy with GitHub Actions
|
||||
> Setup continuous deployment config to enable deploys on a change to files on GitHub
|
||||
|
||||
When you make changes to your docs config or the docs directory, especially editing on GitHub directly, it's often useful to have the docs site build and deploy automatically in a remote environment. This is provided for free by GitHub.
|
||||
|
||||
This action is setup to do that for MkDocs and the Material theme:
|
||||
|
||||
- [deploy-mkdocs](https://github.com/marketplace/actions/deploy-mkdocs) action in marketplace.
|
||||
|
||||
See this implemented in the [workflow](https://github.com/MichaelCurrin/mkdocs-quickstart/blob/master/.github/workflows/docs.yml) file of this MkDocs Quickstart project.
|
||||
59
docs/tutorial/installation.md
Normal file
59
docs/tutorial/installation.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Installation
|
||||
> How to install MkDocs locally.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Python 3](https://www.python.org/)
|
||||
|
||||
|
||||
## Install system dependencies
|
||||
|
||||
<script src="https://gist.github.com/MichaelCurrin/57caae30bd7b0991098e9804a9494c23.js"></script>
|
||||
|
||||
|
||||
## Setup repo
|
||||
|
||||
Choose or setup a MkDocs project.
|
||||
|
||||
- Follow the tutorial page to setup a project.
|
||||
- Or click _Use this template_ on this repo to create your own copy of the repo, then clone it.
|
||||
|
||||
|
||||
## Install project dependencies
|
||||
> Install MkDocs locally
|
||||
|
||||
For more info, see the [Installation](https://www.mkdocs.org/#installation) page on the MkDocs site.
|
||||
|
||||
### Use a virtual environment
|
||||
|
||||
Create a virtual environment at the project root.
|
||||
|
||||
```sh
|
||||
$ python3 -m venv venv
|
||||
```
|
||||
|
||||
Activate it.
|
||||
|
||||
```sh
|
||||
$ source venv/bin/activate
|
||||
```
|
||||
|
||||
Install `mkdocs` from project dependencies list.
|
||||
|
||||
```sh
|
||||
$ pip install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
### Install globally
|
||||
|
||||
If you prefer to install MkDocs once and reuse it across projects, then you can install it globally.
|
||||
|
||||
MkDocs is available using package managers like `apt-get`, `homebrew` and `yum`.
|
||||
|
||||
You can install like this too:
|
||||
|
||||
```sh
|
||||
python3 -m pip install mkdocs
|
||||
```
|
||||
142
docs/tutorial/setup-project.md
Normal file
142
docs/tutorial/setup-project.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Setup project
|
||||
> How to create a MkDocs site from scratch
|
||||
|
||||
This is a summary of the tutorial on [mkdocs.org](https://www.mkdocs.org/).
|
||||
|
||||
|
||||
## How to use this guide
|
||||
|
||||
Use one of the approaches below:
|
||||
|
||||
- Create a quickstart project with the `new` command covered in [Create a starter site](#create-a-starter-site).
|
||||
- Follow the extended guide to create a [Setup up docs site](#setup-a-docs-site) by hand.
|
||||
|
||||
|
||||
### Basic structure
|
||||
|
||||
This is the simplest MkDocs site you can make:
|
||||
|
||||
- `docs/`
|
||||
- `index.md` - Homepage in the `docs` directory (by default).
|
||||
- `mkdocs.yml` - Config at the root.
|
||||
|
||||
|
||||
### Requirements file
|
||||
|
||||
A requirements file is optional but it can make it easier to manage dependencies. If you choose not use the file, make sure `pip install mkdocs` and `pip install THEME` lines are your instructions.
|
||||
|
||||
If you want to add, then include `requirements.txt` at the root. If your project is already a Python project, you might prefer to add `mkdocs` in `requirements-dev.txt` or at `docs/requirements.txt` to keep it isolated.This file should have `mkdocs` in it and also any themes if needed.
|
||||
|
||||
|
||||
### Create a starter site
|
||||
|
||||
Run this command to create a starter site. This make the steps below go quicker.
|
||||
|
||||
```sh
|
||||
cd my-project
|
||||
mkdocs new PATH
|
||||
```
|
||||
|
||||
The result will be same as the [Basic structure](#basic-structure) defined above and will include minimal text content generated by the MkDocs CLI. This text is defined in the project's [new.py](https://github.com/mkdocs/mkdocs/blob/master/mkdocs/commands/new.py) module.
|
||||
|
||||
### Setup a docs site
|
||||
|
||||
_Tip: Optionally use the `new` command covered above to setup the config and index page first and then continue_.
|
||||
|
||||
1. Create doc pages.
|
||||
1. Create a `docs` directory.
|
||||
2. Create `index.md` as your homepage.
|
||||
3. Create other markdown pages (optional).
|
||||
- Use placeholder content if you want to move on and then come back to expand them.
|
||||
- If you have any existing markdown docs, these will work too.
|
||||
2. Setup config.
|
||||
1. Create `mkdocs.yml` at project root.
|
||||
2. Setup a navbar there.
|
||||
3. Choose a theme.
|
||||
3. Create a favicon (optional).
|
||||
- It will be picked up at this path: `docs/img/favicon.ico`.
|
||||
4. Add to your `.gitignore`.
|
||||
- Add build directory. This will prevent it from being versioned on `master` branch.
|
||||
- Add virtual environment, if using one.
|
||||
|
||||
You project should now look this this:
|
||||
|
||||
- `docs/`
|
||||
- `index.md`
|
||||
- Other pages...
|
||||
- `mkdocs.yml`
|
||||
- `.gitignore`
|
||||
- `venv`
|
||||
- `requirements.txt` - optional
|
||||
|
||||
|
||||
## Sample content
|
||||
|
||||
### Ignore file
|
||||
|
||||
`.gitignore`
|
||||
|
||||
```
|
||||
site/
|
||||
|
||||
venv
|
||||
```
|
||||
|
||||
### Navbar
|
||||
|
||||
```yaml
|
||||
nav:
|
||||
- Home: index.md
|
||||
- About: about.md
|
||||
```
|
||||
|
||||
### Themes
|
||||
|
||||
#### Builtin
|
||||
|
||||
Use a builtin theme that comes with MkDocs.
|
||||
|
||||
The default.
|
||||
|
||||
```yaml
|
||||
theme: mkdocs
|
||||
```
|
||||
|
||||
Using ReadTheDocs theme and alternative config syntax.
|
||||
|
||||
```yaml
|
||||
theme:
|
||||
name: readthedocs
|
||||
```
|
||||
|
||||
Find more [supported themes](https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes). If it doesn't immediately, you'll have to use `pip` to install it and add to a `requirements.txt` file.
|
||||
|
||||
#### ReadTheDocs Dropdown theme
|
||||
|
||||
See below using [mkdocs-rtd-dropdown](https://github.com/cjsheets/mkdocs-rtd-dropdown).
|
||||
|
||||
`requirements.txt`
|
||||
```
|
||||
mkdocs-rtd-dropdown
|
||||
```
|
||||
|
||||
`mkdocs.yml`
|
||||
```yaml
|
||||
theme:
|
||||
name: 'rtd-dropdown'
|
||||
```
|
||||
|
||||
### Material for MkdDocs theme
|
||||
|
||||
See the [MkDocs for Material](https://squidfunk.github.io/mkdocs-material/) homepage. See the Setup page for config options.
|
||||
|
||||
`requirements.txt`
|
||||
```
|
||||
mkdocs-material-extensions>=1.0
|
||||
```
|
||||
|
||||
`mkdocs.yml`
|
||||
```yaml
|
||||
theme:
|
||||
name: 'material'
|
||||
```
|
||||
28
docs/tutorial/tldr.md
Normal file
28
docs/tutorial/tldr.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# TL;DR
|
||||
> A simplified version of the tutorial.
|
||||
|
||||
|
||||
## Local setup
|
||||
|
||||
1. [Install](installation.md)
|
||||
- `pip install mkdocs`
|
||||
2. [Setup project](setup-project.md)
|
||||
- `mkdocs new .` or [](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
|
||||
3. [Run](usage.md)
|
||||
- `mkdocs serve`
|
||||
4. View on [http://localhost:8000](http://localhost:8000)
|
||||
|
||||
|
||||
## Deploy to remote site
|
||||
|
||||
### Run deploy command locally
|
||||
|
||||
1. [Deploy](deploy.md) to GitHub Pages
|
||||
- `mkdocs gh-deploy`
|
||||
2. View published site on GitHub Pages at `https://USERNAME.github.io/REPO-NAME/`
|
||||
|
||||
### Run continuous integration
|
||||
|
||||
For CI/CD deploy, use GitHub Actions with an action such as [Deploy MkDocs](https://github.com/marketplace/actions/deploy-mkdocs). Or use Netlify.
|
||||
|
||||
This is not covered in this tutorial.
|
||||
36
docs/tutorial/usage.md
Normal file
36
docs/tutorial/usage.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Usage
|
||||
> Build and preview a site locally
|
||||
|
||||
|
||||
## Serve docs
|
||||
|
||||
This will build the docs in memory (not to disk) and serve an auto-reloading server.
|
||||
|
||||
```sh
|
||||
$ make s
|
||||
```
|
||||
|
||||
That will use `Makefile` to run the following:
|
||||
|
||||
```sh
|
||||
$ mkdocs serve --strict
|
||||
```
|
||||
|
||||
Then open in your browser:
|
||||
|
||||
- [localhost:8000](http://localhost:8000)
|
||||
|
||||
|
||||
## Build docs
|
||||
|
||||
Build docs site to `site` directory. This is useful for a CI flow.
|
||||
|
||||
```sh
|
||||
$ make b
|
||||
```
|
||||
|
||||
That will use `Makefile` to run the following:
|
||||
|
||||
```sh
|
||||
$ mkdocs build --strict
|
||||
```
|
||||
20
mkdocs.yml
20
mkdocs.yml
@@ -1,9 +1,19 @@
|
||||
site_name: MkDocs Quickstart
|
||||
site_description: 'A brief guide for setting up a MkDocs docs site on Github Pages'
|
||||
# For SEO.
|
||||
site_description: "A concise recipe for setting up a MkDocs docs site on GitHub Pages"
|
||||
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Setup and run: setup_and_run.md
|
||||
- Tutorial: tutorial.md
|
||||
- Deploy: deploy.md
|
||||
- Home: index.md
|
||||
- About MkDocs: about-mkdocs.md
|
||||
- Tutorial:
|
||||
- TL;DR: tutorial/tldr.md
|
||||
- Installation: tutorial/installation.md
|
||||
- Setup project: tutorial/setup-project.md
|
||||
- Advanced: tutorial/advanced.md
|
||||
- Usage: tutorial/usage.md
|
||||
- Deploy: tutorial/deploy.md
|
||||
|
||||
theme: readthedocs
|
||||
|
||||
# For the Edit in GitHub button.
|
||||
repo_url: https://github.com/MichaelCurrin/mkdocs-quickstart/
|
||||
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
mkdocs
|
||||
BIN
sample.png
Normal file
BIN
sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 335 KiB |
Reference in New Issue
Block a user