30 Commits

Author SHA1 Message Date
Michael Currin
0ae70d2fcd feat: Update pages 2020-06-02 22:37:33 +02:00
Michael Currin
7b729ba759 docs: Update README.md 2020-06-02 22:37:29 +02:00
Michael Currin
e0d9117274 chore: Create requirements.txt 2020-06-02 22:37:22 +02:00
Michael Currin
928f697e0c feat: Update pages 2020-06-02 22:19:04 +02:00
Michael Currin
f45d546ccf docs: Update README.md 2020-06-02 22:18:57 +02:00
michaelcurrin
3400d5c4bb Update index.md 2020-06-01 10:14:20 +02:00
michaelcurrin
95f5e64589 Update README.md 2020-06-01 10:10:12 +02:00
michaelcurrin
1b92ee3dde Update README.md 2020-06-01 10:08:48 +02:00
michaelcurrin
d2521f69a4 Update setup_project.md 2020-05-20 12:53:20 +02:00
michaelcurrin
e14b88702e Update tldr.md 2020-05-19 13:46:47 +02:00
michaelcurrin
10bb3fabcc Update setup_project.md 2020-05-19 13:41:36 +02:00
michaelcurrin
ddb2e02ac0 Update index.md 2020-05-19 13:38:55 +02:00
michaelcurrin
9a4668db47 Update README.md 2020-05-19 13:33:01 +02:00
michaelcurrin
375db30200 docs: Create sample.png 2020-05-19 13:20:56 +02:00
Michael Currin
15e528c07f feat: Add badges 2020-05-03 11:42:56 +02:00
Michael Currin
b61b9d1a70 feat: Add content 2020-05-03 11:32:14 +02:00
Michael Currin
2d5113a961 chore: Move files to tutorial 2020-05-03 11:31:57 +02:00
Michael Currin
2b4544320b feat: Restructure and add content 2020-05-03 11:17:55 +02:00
Michael Currin
52a8f7862a feat: Update pages 2020-05-03 10:01:04 +02:00
Michael Currin
bdcd8f367c feat: Update tutorial.md 2020-05-03 09:54:10 +02:00
michaelcurrin
cfb5853123 Update index.md 2020-05-03 09:24:15 +02:00
michaelcurrin
d59ed88866 Update tutorial.md 2020-05-03 09:17:27 +02:00
michaelcurrin
7e5650e241 Update tutorial.md 2020-05-03 09:13:03 +02:00
michaelcurrin
dc05d52b62 Update index.md 2020-05-02 23:56:24 +02:00
Michael Currin
3e735f3893 docs: Update description 2020-05-02 23:26:35 +02:00
michaelcurrin
7a07748602 Update setup_and_run.md 2020-05-02 23:24:48 +02:00
Michael Currin
06171073a3 docs: Update description 2020-05-02 23:18:32 +02:00
Michael Currin
0b9cc10056 feat: Update description 2020-05-02 23:18:22 +02:00
Michael Currin
29f21df22c feat: Update pages 2020-05-02 23:17:36 +02:00
Michael Currin
4f2c416522 chore: Create VS Code configs 2020-05-02 22:39:11 +02:00
17 changed files with 501 additions and 112 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"python.pythonPath": "venv/bin/python"
}

51
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,51 @@
{
// 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,2 +1,54 @@
# MkDocs Quickstart
> A brief guide for setting up a MkDocs docs site on Github Pages
> A concise recipe for setting up a MkDocs docs site on Github Pages
[![Made with MkDocs](https://img.shields.io/badge/Made_with-MkDocs-blue.svg)](https://www.mkdocs.org/)
[![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)](https://github.com/MichaelCurrin/mkdocs-quickstart/blob/master/LICENSE)
<!-- TODO When creating a new project copied from this, you can delete this README.md and start over -->
[![GH pages](https://img.shields.io/badge/Github_Pages-MkDocs_Quickstart-green.svg?style=for-the-badge)](https://michaelcurrin.github.io/mkdocs-quickstart/)
[![Use this template](https://img.shields.io/badge/Use_this_template-green.svg?style=for-the-badge)](https://github.com/MichaelCurrin/mkdocs-quickstart/generate)
## Preview
![sample](/sample.png)
## Live site
This project has a site deployed to Github Pages.
_Note: The deploy is currently manually triggered by a local command, however there are Issues open to setup CI/CI remote deploys with Netlify or Github Actions._
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.
## Contributing
Fork this project.
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.
Make any changes you want. Be sure to keep a copy of the original license in the repo. e.g. `cp LICENSE LICENSE-source`.
Create a Pull Request.
## License
Released under [MIT](/LICENSE).

41
docs/about_mkdocs.md Normal file
View File

@@ -0,0 +1,41 @@
# About MkDocs
## What is MkDocs?
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*.
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 ![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.
## 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 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.

View File

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

View File

@@ -1,5 +1,27 @@
# MkDocs Quickstart
> A brief guide for setting up a MkDocs docs site on Github Pages
> A concise recipe for setting up 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)
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**
- [![Use this template](https://img.shields.io/badge/Use_this_template-green.svg)](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.

View File

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

View File

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

63
docs/tutorial/advanced.md Normal file
View File

@@ -0,0 +1,63 @@
# 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
```
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).
## 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>
```

50
docs/tutorial/deploy.md Normal file
View File

@@ -0,0 +1,50 @@
# 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.
_Note this is for a Project Page and not Organization and User Pages._
### Run deploy command
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
```
### Remote build
> How to trigger a rebuild of your docs site on changes
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 without you running a command. A remote build also means you not need to setup Python or MkDocs on your local machine just to get the docs site to work.
So setup a Github Action such as this to your project.
- [deploy-mkdocs](https://github.com/marketplace/actions/deploy-mkdocs) action in marketplace.

View File

@@ -0,0 +1,63 @@
# 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
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 dependencies.
- Directly.
```sh
pip install mkdocs
```
- Or use a `requirements.txt` file with `mkdocs` in it.
```sh
pip install -r requirements.txt
```
### Install globally
If you prefer to install MkDocs once and reuse it across projects, you can install it globally.
MkDocs is available with package managers like `apt-get`, `homebrew` and `yum`.
You can install like this too:
```sh
python3 -m pip install mkdocs
```

View File

@@ -0,0 +1,80 @@
# 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.
### 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 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 it to a `requirements.txt` file.
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.
- e.g.
```
site/
venv
```
You project should now look this this:
- `docs/`
- `index.md`
- Other pages...
- `mkdocs.yml`
- `.gitignore`
- `venv`

28
docs/tutorial/tldr.md Normal file
View 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 [![Use this template](https://img.shields.io/badge/Use_this_template-green.svg)](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.

33
docs/tutorial/usage.md Normal file
View File

@@ -0,0 +1,33 @@
# 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,9 +1,16 @@
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
- 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 adding Edit in Github button.
repo_url: https://github.com/MichaelCurrin/mkdocs-quickstart/

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
mkdocs

BIN
sample.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 KiB