2020-07-16 23:31:39 +03:00
|
|
|
---
|
|
|
|
template: overrides/main.html
|
|
|
|
---
|
|
|
|
|
|
|
|
# Creating your site
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
After you've [installed] Material for MkDocs, you can bootstrap your project
|
2020-07-16 23:31:39 +03:00
|
|
|
documentation using the `mkdocs` executable. Go to the directory where you want
|
|
|
|
your project to be located and enter:
|
|
|
|
|
2020-07-23 15:37:20 +03:00
|
|
|
```
|
2020-07-16 23:31:39 +03:00
|
|
|
mkdocs new .
|
|
|
|
```
|
|
|
|
|
2020-07-22 20:11:22 +03:00
|
|
|
Alternatively, if you're running Material for MkDocs from within Docker, use:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-04-15 22:53:53 +03:00
|
|
|
=== "Unix, Powershell"
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material new .
|
|
|
|
```
|
|
|
|
|
|
|
|
=== "Windows"
|
|
|
|
|
|
|
|
```
|
|
|
|
docker run --rm -it -v "%cd%":/docs squidfunk/mkdocs-material new .
|
|
|
|
```
|
|
|
|
|
|
|
|
This will create the following structure:
|
|
|
|
|
|
|
|
```
|
2020-07-21 19:39:27 +03:00
|
|
|
.
|
2020-07-16 23:31:39 +03:00
|
|
|
├─ docs/
|
|
|
|
│ └─ index.md
|
|
|
|
└─ mkdocs.yml
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[installed]: getting-started.md
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
### Minimal configuration
|
|
|
|
|
2021-01-31 21:23:28 +03:00
|
|
|
Simply add the following lines to `mkdocs.yml` to enable the theme. Note that
|
2021-10-10 23:32:32 +03:00
|
|
|
since there are several [installation methods], minimal configuration might be
|
2021-01-31 21:23:28 +03:00
|
|
|
slightly different:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-28 00:26:07 +03:00
|
|
|
=== ":fontawesome-brands-python: pip"
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-11-15 22:44:51 +03:00
|
|
|
``` yaml
|
|
|
|
theme:
|
|
|
|
name: material
|
|
|
|
```
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-28 00:26:07 +03:00
|
|
|
=== ":fontawesome-brands-docker: docker"
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
theme:
|
|
|
|
name: material
|
|
|
|
```
|
|
|
|
|
|
|
|
=== ":fontawesome-brands-git-alt: git"
|
2020-11-15 22:44:51 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
theme:
|
|
|
|
name: null
|
|
|
|
custom_dir: mkdocs-material/material
|
|
|
|
|
|
|
|
# 404 page
|
|
|
|
static_templates:
|
|
|
|
- 404.html
|
|
|
|
|
|
|
|
# Necessary for search to work properly
|
|
|
|
include_search_page: false
|
|
|
|
search_index_only: true
|
|
|
|
|
|
|
|
# Default values, taken from mkdocs_theme.yml
|
|
|
|
language: en
|
|
|
|
font:
|
|
|
|
text: Roboto
|
|
|
|
code: Roboto Mono
|
|
|
|
favicon: assets/favicon.png
|
|
|
|
icon:
|
|
|
|
logo: logo
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
When you clone from GitHub, you must list all of the themes' defaults
|
|
|
|
explicitly, because [`mkdocs_theme.yml`][mkdocs_theme.yml] is not
|
|
|
|
loaded automatically as described in the [custom theme guide].
|
2020-11-15 22:44:51 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[installation methods]: getting-started.md#installation
|
|
|
|
[mkdocs_theme.yml]: https://github.com/squidfunk/mkdocs-material/blob/master/src/mkdocs_theme.yml
|
|
|
|
[custom theme guide]: https://www.mkdocs.org/user-guide/custom-themes/#creating-a-custom-theme
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
### Advanced configuration
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Material for MkDocs comes with many configuration options. The setup section
|
2020-12-21 19:38:58 +03:00
|
|
|
explains in great detail how to configure and customize colors, fonts, icons
|
|
|
|
and much more:
|
|
|
|
|
2021-10-05 00:36:31 +03:00
|
|
|
<div class="mdx-columns" markdown>
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
- [Changing the colors]
|
|
|
|
- [Changing the fonts]
|
|
|
|
- [Changing the language]
|
|
|
|
- [Changing the logo and icons]
|
|
|
|
- [Setting up navigation]
|
|
|
|
- [Setting up site search]
|
|
|
|
- [Setting up site analytics]
|
|
|
|
- [Setting up social cards]
|
|
|
|
- [Setting up tags]
|
|
|
|
- [Setting up versioning]
|
|
|
|
- [Setting up the header]
|
|
|
|
- [Setting up the footer]
|
|
|
|
- [Adding a git repository]
|
|
|
|
- [Adding a comment system]
|
2020-11-15 22:44:51 +03:00
|
|
|
|
2020-12-21 19:38:58 +03:00
|
|
|
</div>
|
|
|
|
|
2021-11-07 20:23:01 +03:00
|
|
|
Furthermore, see the list of supported [Markdown extensions] that are natively
|
|
|
|
integrated with Material for MkDocs, delivering a low-effort and unprecedented
|
|
|
|
technical writing experience.
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[Changing the colors]: setup/changing-the-colors.md
|
|
|
|
[Changing the fonts]: setup/changing-the-fonts.md
|
|
|
|
[Changing the language]: setup/changing-the-language.md
|
|
|
|
[Changing the logo and icons]: setup/changing-the-logo-and-icons.md
|
|
|
|
[Setting up navigation]: setup/setting-up-navigation.md
|
|
|
|
[Setting up site search]: setup/setting-up-site-search.md
|
|
|
|
[Setting up site analytics]: setup/setting-up-site-analytics.md
|
|
|
|
[Setting up social cards]: setup/setting-up-social-cards.md
|
|
|
|
[Setting up tags]: setup/setting-up-tags.md
|
|
|
|
[Setting up versioning]: setup/setting-up-versioning.md
|
|
|
|
[Setting up the header]: setup/setting-up-the-header.md
|
|
|
|
[Setting up the footer]: setup/setting-up-the-footer.md
|
|
|
|
[Adding a git repository]: setup/adding-a-git-repository.md
|
|
|
|
[Adding a comment system]: setup/adding-a-comment-system.md
|
2021-11-07 20:23:01 +03:00
|
|
|
[Markdown extensions]: setup/extensions/index.md
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
## Previewing as you write
|
|
|
|
|
|
|
|
MkDocs includes a live preview server, so you can preview your changes as you
|
|
|
|
write your documentation. The server will automatically rebuild the site upon
|
|
|
|
saving. Start it with:
|
|
|
|
|
2021-10-30 14:29:35 +03:00
|
|
|
``` sh
|
2021-12-11 16:30:07 +03:00
|
|
|
mkdocs serve # (1)!
|
2020-07-16 23:31:39 +03:00
|
|
|
```
|
2021-10-30 14:29:35 +03:00
|
|
|
|
|
|
|
1. If you have a large documentation project, it might take minutes until
|
|
|
|
MkDocs has rebuilt all pages for you to preview. If you're only interested
|
2021-10-30 14:41:50 +03:00
|
|
|
in the current page, the [`--dirtyreload`][--dirtyreload] flag will make
|
|
|
|
rebuilds much faster:
|
2021-10-30 14:29:35 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
mkdocs serve --dirtyreload
|
|
|
|
```
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
If you're running Material for MkDocs from within Docker, use:
|
|
|
|
|
2021-04-15 22:53:53 +03:00
|
|
|
=== "Unix, Powershell"
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material
|
|
|
|
```
|
|
|
|
|
|
|
|
=== "Windows"
|
|
|
|
|
|
|
|
```
|
|
|
|
docker run --rm -it -p 8000:8000 -v "%cd%":/docs squidfunk/mkdocs-material
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Point your browser to [localhost:8000][live preview] and you should see:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[![Creating your site]][Creating your site]
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-30 14:41:50 +03:00
|
|
|
[--dirtyreload]: https://www.mkdocs.org/about/release-notes/#support-for-dirty-builds-990
|
2021-10-10 23:32:32 +03:00
|
|
|
[live preview]: http://localhost:8000
|
|
|
|
[Creating your site]: assets/screenshots/creating-your-site.png
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
## Building your site
|
|
|
|
|
|
|
|
When you're finished editing, you can build a static site from your Markdown
|
|
|
|
files with:
|
|
|
|
|
|
|
|
```
|
|
|
|
mkdocs build
|
|
|
|
```
|
|
|
|
|
|
|
|
The contents of this directory make up your project documentation. There's no
|
|
|
|
need for operating a database or server, as it is completely self-contained.
|
2021-10-10 23:32:32 +03:00
|
|
|
The site can be hosted on [GitHub Pages], [GitLab Pages], a CDN of your choice
|
|
|
|
or your private web space.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[GitHub Pages]: publishing-your-site.md#github-pages
|
|
|
|
[GitLab pages]: publishing-your-site.md#gitlab-pages
|