51 Commits

Author SHA1 Message Date
Michael Currin
566de0e514 docs: Update docs 2020-10-17 17:33:03 +02:00
Michael Currin
8bd56b6906 docs: Update about-mkdocs.md 2020-10-17 17:30:12 +02:00
Michael Currin
2b289a59b0 chore: Update requirements.txt 2020-10-17 17:29:41 +02:00
Michael Currin
3f0006ac82 docs: Update README.md 2020-10-17 17:25:17 +02:00
Michael Currin
76e04dde8e ci: Fix path of cache 2020-10-17 17:24:30 +02:00
Michael Currin
8601582a74 ci: Add cache step 2020-10-17 17:21:54 +02:00
Michael Currin
f22c1fe04d docs: Update deploy.md 2020-10-17 17:17:05 +02:00
Michael Currin
e577bb912b docs: Update instructions 2020-10-17 17:10:04 +02:00
Michael Currin
887d08bc3c ci: Update docs.yml 2020-10-17 17:09:57 +02:00
Michael Currin
473580b7d6 docs: Update README.md 2020-10-17 17:00:49 +02:00
Michael Currin
99fb0757c7 chore: Move to docs directory 2020-10-17 17:00:45 +02:00
Michael Currin
a028e5c228 docs: Update README.md 2020-10-17 16:55:46 +02:00
Michael Currin
49d6ee84a7 docs: Update docs 2020-10-17 16:54:30 +02:00
Michael Currin
f21ac0fe3c chore: Delete tasks.json 2020-10-17 16:54:23 +02:00
Michael Currin
3b5f31d73d ci: Update and use deploy target 2020-10-17 16:48:56 +02:00
Michael Currin
3a743ae48f docs: Update deploy.md 2020-10-17 16:45:45 +02:00
Michael Currin
fdbbb73cd6 chore: Rename main.yml to docs.yml 2020-10-17 16:45:20 +02:00
Michael Currin
953967dda8 ci: Update main.yml 2020-10-17 16:45:02 +02:00
Michael Currin
35ce122bd8 ci: Remove use of action 2020-10-17 16:44:00 +02:00
Michael Currin
89fbc16c26 chore: Update Makefile 2020-10-17 16:34:24 +02:00
Michael Currin
e7800bc936 docs: Update usage.md 2020-10-17 16:34:21 +02:00
Michael Currin
54be3ff415 docs: Update deploy.md 2020-10-17 16:34:18 +02:00
Michael Currin
b48560c99d docs: Update README.md 2020-10-17 16:27:29 +02:00
Michael Currin
d14aca853a chore: Update Makefile 2020-10-17 16:24:02 +02:00
Michael Currin
11c1377a9f chore: Update Makefile 2020-10-17 16:23:41 +02:00
Michael Currin
5e8b217c8d docs: Update docs 2020-10-17 16:23:20 +02:00
Michael Currin
b842ce958e docs: Rename Github to GitHub 2020-10-17 15:01:58 +02:00
Michael Currin
787dc334a1 ci: Update main.yml 2020-10-17 15:00:21 +02:00
Michael Currin
286e8c6f0d ci: Upgrade action version 2020-10-16 17:58:07 +02:00
Michael Currin
1decccd809 Update README.md 2020-10-16 17:57:15 +02:00
Michael Currin
6bef7960f0 Update README.md 2020-10-16 17:55:24 +02:00
Michael Currin
645a052e22 ci: Update main.yml 2020-10-15 11:51:20 +02:00
Michael Currin
da67a34443 chore: Update mkdocs.yml 2020-10-15 11:50:48 +02:00
Michael Currin
4a9f27222a ci: Update main.yml 2020-10-15 11:05:59 +02:00
Michael Currin
8feabd1a43 chore: Update mkdocs.yml 2020-10-15 11:00:13 +02:00
Michael Currin
ae37b3874d docs: Update advanced.md 2020-10-15 10:54:27 +02:00
Michael Currin
3630bab42c docs: Update setup-project.md 2020-10-15 10:54:23 +02:00
Michael Currin
4726a67ef3 chore: Update mkdocs.yml 2020-10-15 10:52:13 +02:00
Michael Currin
c25398473f docs: Update pages 2020-10-15 10:43:47 +02:00
Michael Currin
b27fe05ebe chore: Create Makefile 2020-10-15 10:43:20 +02:00
Michael Currin
01e7c407b0 style: Dedent 2020-10-15 10:43:17 +02:00
Michael Currin
8434d546bb chore: Update LICENSE 2020-10-15 10:42:52 +02:00
Michael Currin
4753edcbe9 Update README.md 2020-10-14 23:15:02 +02:00
Michael Currin
7e69b48377 Update mkdocs.yml 2020-10-14 23:12:27 +02:00
Michael Currin
6a5cfe2377 Update main.yml 2020-10-14 23:11:56 +02:00
Michael Currin
7177e48983 Update README.md 2020-10-14 23:04:14 +02:00
Michael Currin
989e13de5e Update mkdocs.yml 2020-10-14 23:01:19 +02:00
Michael Currin
4c169b9981 Update installation.md 2020-10-14 22:59:32 +02:00
Michael Currin
81e9147b2b Update README.md 2020-10-14 22:55:56 +02:00
Michael Currin
6f7122d7cd Update README.md 2020-10-14 22:47:36 +02:00
Michael Currin
f537e68f5f Update README.md 2020-10-14 22:46:38 +02:00
20 changed files with 344 additions and 262 deletions

32
.github/workflows/docs.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Deploy docs
on:
push:
branches:
- master
jobs:
build-deploy:
name: Build and deploy to GH Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: cd docs && make install
- name: Build and deploy
run: cd docs && make deploy

View File

@@ -1,22 +0,0 @@
name: Deploy docs
on:
push:
branches:
- master
paths:
- 'docs/**'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Deploy to GH Pages
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

51
.vscode/tasks.json vendored
View File

@@ -1,51 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "${config:python.pythonPath}",
"args": ["-m", "mkdocs", "build"],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "serve",
"type": "process",
"command": "${config:python.pythonPath}",
"args": ["-m", "mkdocs", "serve"],
"problemMatcher": [],
},
{
"label": "deploy",
"type": "process",
"command": "${config:python.pythonPath}",
"args": ["-m", "mkdocs", "gh-deploy"],
"problemMatcher": [],
},
// Reference globally-installed MkDocs.
{
"label": "build-global",
"type": "shell",
"command": "mkdocs build",
"problemMatcher": [],
},
{
"label": "serve-global",
"type": "shell",
"command": "mkdocs serve",
"problemMatcher": [],
},
{
"label": "deploy-global",
"type": "shell",
"command": "mkdocs gh-deploy",
"problemMatcher": [],
}
]
}

View File

@@ -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

View File

@@ -1,35 +1,46 @@
# MkDocs Quickstart
> A template, live demo and tutorial for how to setup a MkDocs docs site on GitHub Pages
![CI status](https://github.com/MichaelCurrin/mkdocs-quickstart/workflows/Deploy%20docs/badge.svg)
[![CI status](https://github.com/MichaelCurrin/mkdocs-quickstart/workflows/Deploy%20docs/badge.svg)](https://github.com/MichaelCurrin/mkdocs-quickstart/actions)
[![Made with MkDocs](https://img.shields.io/badge/Made_with-MkDocs-blue)](https://www.mkdocs.org/)
[![Made with GH Actions](https://img.shields.io/badge/Made_with-GH_Actions-blue?logo=github-actions&logoColor=white)](https://github.com/features/actions)
[![GitHub tag](https://img.shields.io/github/tag/MichaelCurrin/mkdocs-quickstart.svg)](https://GitHub.com/MichaelCurrin/mkdocs-quickstart/tags/)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](#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
[![Sample screenshot](/sample.png)](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">
[![GH Pages](https://img.shields.io/badge/Github_Pages-MkDocs_Quickstart-green?style=for-the-badge)](https://michaelcurrin.github.io/mkdocs-quickstart/)
[![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f?style=for-the-badge)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
[![GH Pages](https://img.shields.io/badge/GitHub_Pages-MkDocs_Quickstart-green?style=for-the-badge)](https://michaelcurrin.github.io/mkdocs-quickstart/)
[![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f?style=for-the-badge&logo=github)](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.
- Uses a deploy pipeline on GH Actions to deploy a GH Pages site.
- A **markdown-based** docs site which is easy to edit - see the content in the [docs](/docs/docs/) directory.
- Easy to **configure** - see the short [mkdocs.yml](/docs/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
@@ -46,8 +57,10 @@ This repo also doubles as a template to create a new project from. Click the but
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?
## 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.
@@ -63,8 +76,8 @@ 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.
2. Set up the project locally - follow the instructions on the live tutorial or in the [TL;DR](/docs/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.

22
docs/Makefile Normal file
View 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

View File

@@ -7,7 +7,7 @@ The description on the MkDocs site is:
> Project documentation with Markdown.
MkDocs is a Python tool generates a static site based on content written in *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.
@@ -17,12 +17,13 @@ If you are new to markdown, see the [Getting Started](https://www.markdownguide.
- [mkdocs.org](https://www.mkdocs.org) homepage
- [mkdocs/mkdocs ![Repo stars](https://img.shields.io/github/stars/mkdocs/mkdocs?style=social)](https://github.com/mkdocs/mkdocs)
- [MkDocs Wiki](https://github.com/mkdocs/mkdocs/wiki) - covering themes, plugins, recipes and more.
- [Release notes](https://www.mkdocs.org/about/release-notes/)
## Reasons to use MkDocs
- Create an elegant, modern docs site for your project.
- Create a static site and serve from Github Pages easily.
- 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.
@@ -37,4 +38,4 @@ If you are new to markdown, see the [Getting Started](https://www.markdownguide.
## Do I need to know Python?
MkDocs is built in Python (like Sphynx), but you don't have to write Python code. If you setup a [Deploy](deloy) flow right, you don't even have to set it up locally, though then you can't preview.
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.

View File

@@ -1,5 +1,5 @@
# MkDocs Quickstart
> A template, live demo and tutorial for how to setup a MkDocs docs site on Github Pages
> A template, live demo and tutorial for how to setup a MkDocs docs site on GitHub Pages
[![Repo stars](https://img.shields.io/github/stars/MichaelCurrin/mkdocs-quickstart?style=social)](https://github.com/MichaelCurrin/mkdocs-quickstart)
@@ -17,9 +17,9 @@ Follow the tutorial to add an existing project or create a project from scratch.
- Run it locally.
- Deploy it.
- **Add a copy of this project to your repos**
- [![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
- [![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f?logo=github)](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.
- 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.

View File

@@ -1,7 +1,7 @@
# 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).
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
@@ -10,24 +10,14 @@ 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
- Home: index.md
- About: about.md
- Foo:
- Overview: foo/index.md
- Bar: foo/bar.md
```
However, adding a path when nesting as below is **invalid** and will give an error:
```yaml
nav:
- Home: index.md
- About: about.md
- Foo: foo/index.md
- Bar: foo/bar.md
```
See [issue #1139](https://github.com/mkdocs/mkdocs/issues/1139).
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

View File

@@ -0,0 +1,60 @@
# 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 GitHub Actions](#deploy-with-github-actions) - use the project's workflow to build and deploy to GH Pages on commits pushed to master.
_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.
See the [docs.yml](https://github.com/MichaelCurrin/mkdocs-quickstart/blob/master/.github/workflows/docs.yml) workflow provided with this project. You don't have to change anything there. The token will be generated for you by GitHub Actions.

View File

@@ -16,8 +16,21 @@
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.
Follow the tutorial page to setup a project.
Or click the button on this repo to create your own copy of the repo.
[![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f?style=for-the-badge&logo=github)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
Then clone it.
e.g.
```sh
$ git clone git@github.com:MichaelCurrin/mkdocs-quickstart.git
$ cd mkdocs-quickstart
```
## Install project dependencies
@@ -30,28 +43,22 @@ For more info, see the [Installation](https://www.mkdocs.org/#installation) page
Create a virtual environment at the project root.
```sh
python3 -m venv venv
$ python3 -m venv venv
```
Activate it.
```sh
source venv/bin/activate
$ source venv/bin/activate
```
Install dependencies using one of these approaches:
Install `mkdocs` from the project dependencies list.
<!-- Using `sh` for code block breaks for bullet points at least for read the docs theme -->
```sh
$ cd docs
$ pip install -r requirements.txt
```
- Install directly.
```bash
pip install mkdocs
```
- Create a `requirements.txt` file, add `mkdocs` to it then install from the file.
```bash
echo 'mkdocs' > requirements.txt
pip install -r requirements.txt
```
### Install globally

View File

@@ -25,7 +25,7 @@ This is the simplest MkDocs site you can make:
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 `dev-requirements.txt` or at `docs/requirements.txt` to keep it isolated.This file should have `mkdocs` in it and also any themes if needed.
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
@@ -39,7 +39,6 @@ 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_.
@@ -52,30 +51,13 @@ _Tip: Optionally use the `new` command covered above to setup the config and ind
- If you have any existing markdown docs, these will work too.
2. Setup config.
1. Create `mkdocs.yml` at project root.
2. Setup navbar there. e.g.
```yaml
nav:
- Home: index.md
- About: about.md
```
3. Choose a theme.
- An example of choosing a theme which is builtin:
```yaml
theme: 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.
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.
- For example:
```
site/
venv
```
You project should now look this this:
@@ -86,3 +68,75 @@ You project should now look this this:
- `.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'
```

View File

@@ -6,23 +6,23 @@
1. [Install](installation.md)
- `pip install mkdocs`
2. [Setup project](setup_project.md)
- `mkdocs new .` or [![Use this template](https://img.shields.io/badge/Use_this_template-green.svg)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
2. [Setup project](setup-project.md)
- `mkdocs new .` or [![Use this template](https://img.shields.io/badge/Use_this_template-2ea44f&logo=github)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
3. [Run](usage.md)
- `mkdocs serve`
4. View on [http://localhost:8000](http://localhost:8000)
4. View on [localhost:8000](http://localhost:8000)
## Deploy to remote site
### Run deploy command locally
1. [Deploy](deploy.md) to Github Pages
1. [Deploy](deploy.md) to GitHub Pages
- `mkdocs gh-deploy`
2. View published site on Github Pages at `https://USERNAME.github.io/REPO-NAME/`
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.
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.

View File

@@ -0,0 +1,67 @@
# Usage
> Build and preview a site locally
Make sure to run all commands from the `docs` directory.
```sh
$ cd docs
```
## CLI help
```sh
$ make help
```
```
.PHONY: docs
default: install
h help:
install:
s serve:
b build:
d deploy:
```
## 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
```

19
docs/mkdocs.yml Normal file
View File

@@ -0,0 +1,19 @@
site_name: MkDocs Quickstart
# SEO description.
site_description: "A concise recipe for setting up a MkDocs docs site on GitHub Pages"
nav:
- 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
# Target for Edit in GitHub button.
repo_url: https://github.com/MichaelCurrin/mkdocs-quickstart/

1
docs/requirements.txt Normal file
View File

@@ -0,0 +1 @@
mkdocs~=1.1

View File

@@ -1,58 +0,0 @@
# 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 and not Organization or User Pages._
### 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
mkdocs gh-deploy
```
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 continous 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:
- [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/main.yml) file of this MkDocs Quickstart project.

View File

@@ -1,33 +0,0 @@
# Usage
> Build and preview a site locally
_Note: If using VS Code, you can use the command palette instead to run the configured tasks - these are setup in `.vscode/tasks.json`._
## Serve docs
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. Useful for production build or simulating that locally.
```sh
mkdocs build
```
Add this flag to remove stale files when building.
```sh
mkdocs build --clean
```

View File

@@ -1,19 +0,0 @@
site_name: MkDocs Quickstart
# For SEO.
site_description: 'A concise recipe for setting up a MkDocs docs site on GitHub Pages'
nav:
- 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
# URL for the Edit in GitHub button.
repo_url: https://github.com/MichaelCurrin/mkdocs-quickstart/

View File

@@ -1 +0,0 @@
mkdocs