diff --git a/.markdownlintrc b/.markdownlintrc index 620a42b6..8a3a069d 100644 --- a/.markdownlintrc +++ b/.markdownlintrc @@ -12,5 +12,8 @@ "MD007": { "indent": 4 }, // Exclude code block style - "MD046": false + "MD046": false, + + // Allow inline HTML + "MD033": false } diff --git a/docs/about/release-notes.md b/docs/about/release-notes.md index 60a2ad91..cf40ab99 100644 --- a/docs/about/release-notes.md +++ b/docs/about/release-notes.md @@ -67,7 +67,7 @@ MkDocs can now benefit from recent bug fixes and new features, including the fol Plugin developers can now use the `on_build_error` hook to execute code when an exception is raised while building the site. -See [`on_build_error`](../user-guide/plugins.md#on_build_error) +See [`on_build_error`](../dev-guide/plugins.md#on_build_error) in the Plugins documentation for details. #### Two new exceptions: BuildError and PluginError (#2103) @@ -80,7 +80,7 @@ MkDocs now has two new exceptions defined in `mkdocs.exceptions`, * `BuildError` should not be used by third-party plugins developers and is reserved for internal use only. -See [`Handling errors`](../user-guide/plugins.md#handling-errors) +See [`Handling errors`](../dev-guide/plugins.md#handling-errors) in the Plugins documentation for details. #### Search Indexing Strategy configuration @@ -119,6 +119,7 @@ up horizontal space for better rendering of content like tables (#2193). property to accomodate this possible dynamic behavior. See #2305. * Updated highlight.js to 10.5.0. See #2313. * Bugfix: Search plugin now works with Japanese language. See #2178. +* Documentation has been refactored (#1629). ## Version 1.1.2 (2020-05-14) @@ -162,7 +163,7 @@ mirror the upstream configuration options. See the [theme documentation][rtd-docs] for details. [upstream]: https://github.com/rtfd/sphinx_rtd_theme/ -[rtd-docs]: ../user-guide/styling-your-docs.md#readthedocs +[rtd-docs]: ../user-guide/choosing-your-theme.md#readthedocs #### Update `mkdocs` theme to Bootswatch 4.1.3 (#1563) @@ -278,7 +279,7 @@ The changes included in the refactor are summarized below. files not in the `docs_dir`, exclude files, redefine page URLs (i.e. implement extensionless URLs), or to manipulate files in various other ways. - [on_files]: ../user-guide/plugins.md#on_files +[on_files]: ../dev-guide/plugins.md#on_files ##### Backward Incompatible Changes @@ -384,8 +385,8 @@ need to will be altered. {% endfor %} ``` -[base_url]: ../user-guide/custom-themes.md#base_url -[url]: ../user-guide/custom-themes.md#url +[base_url]: ../dev-guide/themes.md#base_url +[url]: ../dev-guide/themes.md#url #### Path Based Settings are Relative to Configuration File (#543) @@ -453,7 +454,7 @@ Users can review the [configuration options][search config] available and theme authors should review how [search and themes] interact. [search config]: ../user-guide/configuration.md#search -[search and themes]: ../user-guide/custom-themes.md#search_and_themes +[search and themes]: ../dev-guide/themes.md#search_and_themes #### `theme_dir` Configuration Option fully Deprecated @@ -537,7 +538,7 @@ then the `search` plugin will be included by default. See the [configuration][plugin_config] documentation for information on overriding the default. -[Plugin API]: ../user-guide/plugins.md +[Plugin API]: ../dev-guide/plugins.md [plugin_config]: ../user-guide/configuration.md#plugins #### Theme Customization. (#1164) @@ -574,7 +575,7 @@ theme: See the [theme] configuration option documentation for details. -[Theme Configuration]: ../user-guide/custom-themes.md#theme-configuration +[Theme Configuration]: ../dev-guide/themes.md#theme-configuration [theme]: ../user-guide/configuration.md#theme [custom_dir]: ../user-guide/configuration.md#custom_dir @@ -592,7 +593,7 @@ template exists. ##### Context Variables Page specific variable names in the template context have been refactored as -defined in [Custom Themes](../user-guide/custom-themes.md#page). The +defined in [Custom Themes](../dev-guide/themes.md#page). The old variable names issued a warning in version 0.16, but have been removed in version 1.0. @@ -610,14 +611,14 @@ user created and third-party templates: | previous_page | [page.previous_page]| | next_page | [page.next_page] | -[page]: ../user-guide/custom-themes.md#page -[page.title]: ../user-guide/custom-themes.md#pagetitle -[page.content]: ../user-guide/custom-themes.md#pagecontent -[page.toc]: ../user-guide/custom-themes.md#pagetoc -[page.meta]: ../user-guide/custom-themes.md#pagemeta -[page.canonical_url]: ../user-guide/custom-themes.md#pagecanonical_url -[page.previous_page]: ../user-guide/custom-themes.md#pageprevious_page -[page.next_page]: ../user-guide/custom-themes.md#pagenext_page +[page]: ../dev-guide/themes.md#page +[page.title]: ../dev-guide/themes.md#pagetitle +[page.content]: ../dev-guide/themes.md#pagecontent +[page.toc]: ../dev-guide/themes.md#pagetoc +[page.meta]: ../dev-guide/themes.md#pagemeta +[page.canonical_url]: ../dev-guide/themes.md#pagecanonical_url +[page.previous_page]: ../dev-guide/themes.md#pageprevious_page +[page.next_page]: ../dev-guide/themes.md#pagenext_page Additionally, a number of global variables have been altered and/or removed and user created and third-party templates should be updated as outlined below: @@ -697,7 +698,7 @@ the `extra_css` or `extra_javascript` config settings going forward. ##### Page Context Page specific variable names in the template context have been refactored as -defined in [Custom Themes](../user-guide/custom-themes.md#page). The +defined in [Custom Themes](../dev-guide/themes.md#page). The old variable names will issue a warning but continue to work for version 0.16, but may be removed in a future version. @@ -715,14 +716,14 @@ user created and third-party templates: | previous_page | [page.previous_page]| | next_page | [page.next_page] | -[page]: ../user-guide/custom-themes.md#page -[page.title]: ../user-guide/custom-themes.md#pagetitle -[page.content]: ../user-guide/custom-themes.md#pagecontent -[page.toc]: ../user-guide/custom-themes.md#pagetoc -[page.meta]: ../user-guide/custom-themes.md#pagemeta -[page.canonical_url]: ../user-guide/custom-themes.md#pagecanonical_url -[page.previous_page]: ../user-guide/custom-themes.md#pageprevious_page -[page.next_page]: ../user-guide/custom-themes.md#pagenext_page +[page]: ../dev-guide/themes.md#page +[page.title]: ../dev-guide/themes.md#pagetitle +[page.content]: ../dev-guide/themes.md#pagecontent +[page.toc]: ../dev-guide/themes.md#pagetoc +[page.meta]: ../dev-guide/themes.md#pagemeta +[page.canonical_url]: ../dev-guide/themes.md#pagecanonical_url +[page.previous_page]: ../dev-guide/themes.md#pageprevious_page +[page.next_page]: ../dev-guide/themes.md#pagenext_page ##### Global Context @@ -811,7 +812,7 @@ overriding blocks in the same manner as the built-in themes. Third party themes are encouraged to wrap the various pieces of their templates in blocks in order to support such customization. -[blocks]: ../user-guide/styling-your-docs.md#overriding-template-blocks +[blocks]: ../user-guide/customizing-your-theme.md#overriding-template-blocks #### Auto-Populated `extra_css` and `extra_javascript` Deprecated. (#986) @@ -929,12 +930,12 @@ They will be included with MkDocs by default until a future release. After that they will be installable with pip: `pip install mkdocs-bootstrap` and `pip install mkdocs-bootswatch` -See the documentation for [Styling your docs] for more information about using +See the documentation for [Customizing Your Theme] for more information about using and customizing themes and [Custom themes] for creating and distributing new themes -[Styling your docs]: ../user-guide/styling-your-docs.md -[Custom themes]: ../user-guide/custom-themes.md +[Customizing Your Theme]: ../user-guide/customizing-your-theme.md +[Custom themes]: ../dev-guide/themes.md ### Other Changes and Additions to Version 0.15.0 @@ -957,7 +958,7 @@ themes [site_description]: ../user-guide/configuration.md#site_description [site_author]: ../user-guide/configuration.md#site_author -[ReadTheDocs]: ../user-guide/styling-your-docs.md#readthedocs +[ReadTheDocs]: ../user-guide/choosing-your-theme.md#readthedocs ## Version 0.14.0 (2015-06-09) @@ -1042,7 +1043,7 @@ JavaScript library [lunr.js]. It has been added to both the `mkdocs` and for adding it to your own themes. [lunr.js]: https://lunrjs.com/ -[supporting search]: ../user-guide/styling-your-docs.md#search-and-themes +[supporting search]: ../dev-guide/themes.md#search-and-themes #### New Command Line Interface @@ -1073,7 +1074,7 @@ documentation. [extra_javascript]: ../user-guide/configuration.md#extra_javascript [extra_css]: ../user-guide/configuration.md#extra_css [extra_templates]: ../user-guide/configuration.md#extra_templates -[global variables]: ../user-guide/styling-your-docs.md#global-context +[global variables]: ../dev-guide/themes.md#global-context ### Other Changes and Additions to Version 0.13.0 diff --git a/docs/css/extra.css b/docs/css/extra.css index 29f4d9a4..cf2d58e5 100644 --- a/docs/css/extra.css +++ b/docs/css/extra.css @@ -25,3 +25,25 @@ code.no-highlight { dd { padding-left: 20px; } + +/* Homepage */ + +body.homepage div.jumbotron { + margin-top: 1.5rem; + padding-top: 1rem; + padding-bottom: 0; +} + +body.homepage div.jumbotron div.card { + margin-bottom: 2rem; +} + +body.homepage>div.container>div.row>div.col-md-3 { + display: none; +} + +body.homepage>div.container>div.row>div.col-md-9 { + margin-left: 0; + flex: 0 0 100%; + max-width: 100%; +} diff --git a/docs/dev-guide/index.md b/docs/dev-guide/index.md new file mode 100644 index 00000000..f0124c90 --- /dev/null +++ b/docs/dev-guide/index.md @@ -0,0 +1,16 @@ +# Developer Guide + +Extending MkDocs + +--- + +The MkDocs Developer Guide provides documentation for developers of third +party themes and plugins. Please see the [Contributing Guide] for information +on contributing to MkDocs itself. You can jump directly to a page listed +below, or use the *next* and *previous* buttons in the navigation bar at the +top of the page to move through the documention in order. + +- [Themes](themes.md) +- [Plugins](plugins.md) + +[Contributing Guide]: ../about/contributing.md diff --git a/docs/user-guide/plugins.md b/docs/dev-guide/plugins.md similarity index 98% rename from docs/user-guide/plugins.md rename to docs/dev-guide/plugins.md index adaed745..efbda3ae 100644 --- a/docs/user-guide/plugins.md +++ b/docs/dev-guide/plugins.md @@ -472,16 +472,16 @@ Note that registering a plugin does not activate it. The user still needs to tell MkDocs to use it via the config. [BasePlugin]:#baseplugin -[config]: configuration.md#plugins +[config]: ../user-guide/configuration.md#plugins [entry point]: #entry-point [env]: #on_env [events]: #events -[extra_templates]: configuration.md#extra_templates +[extra_templates]: ../user-guide/configuration.md#extra_templates [Global Events]: #global-events [Page Events]: #page-events [post_build]: #on_post_build [post_template]: #on_post_template -[static_templates]: configuration.md#static_templates +[static_templates]: ../user-guide/configuration.md#static_templates [Template Events]: #template-events [MkDocs Plugins]: https://github.com/mkdocs/mkdocs/wiki/MkDocs-Plugins [on_build_error]: #on_build_error diff --git a/docs/user-guide/custom-themes.md b/docs/dev-guide/themes.md similarity index 92% rename from docs/user-guide/custom-themes.md rename to docs/dev-guide/themes.md index 96aec56a..26e352a7 100644 --- a/docs/user-guide/custom-themes.md +++ b/docs/dev-guide/themes.md @@ -1,4 +1,4 @@ -# Custom themes +# Developing Themes A guide to creating and distributing custom themes. @@ -6,24 +6,27 @@ A guide to creating and distributing custom themes. !!! Note - If you are looking for third party themes, they are listed in the MkDocs - [community wiki](https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes). If - you want to share a theme you create, you should list it on the Wiki. + If you are looking for existing third party themes, they are listed in the + MkDocs [community wiki]. If you want to share a theme you create, you + should list it on the Wiki. When creating a new theme, you can either follow the steps in this guide to create one from scratch or you can download the `mkdocs-basic-theme` as a basic, yet complete, theme with all the boilerplate required. **You can find -this base theme on [GitHub](https://github.com/mkdocs/mkdocs-basic-theme)**. -It contains detailed comments in the code to describe the different features -and their usage. +this base theme on [GitHub][basic theme]**. It contains detailed comments in +the code to describe the different features and their usage. + +[community wiki]: https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes +[basic theme]: https://github.com/mkdocs/mkdocs-basic-theme ## Creating a custom theme -The bare minimum required for a custom theme is a `main.html` [Jinja2 template] -file which is placed in a directory that is *not* a child of the [docs_dir]. -Within `mkdocs.yml`, set the theme.[custom_dir] option to the path of the -directory containing `main.html`. The path should be relative to the -configuration file. For example, given this example project layout: +The bare minimum required for a custom theme is a `main.html` [Jinja2 +template] file which is placed in a directory that is *not* a child of the +[docs_dir]. Within `mkdocs.yml`, set the [`theme.custom_dir`][custom_dir] +option to the path of the directory containing `main.html`. The path should be +relative to the configuration file. For example, given this example project +layout: ```no-highlight mkdocs.yml @@ -56,7 +59,7 @@ theme: `mkdocs` theme would remain unchanged. This is useful if you want to make small adjustments to an existing theme. - For more specific information, see [styling your docs]. + For more specific information, see [Customizing Your Theme]. !!! Warning @@ -69,13 +72,13 @@ theme: the `theme.name` configuration option, then a `mkdocs_theme.yml` file is required for the theme. -[styling your docs]: ./styling-your-docs.md#using-the-theme-custom_dir -[custom_dir]: ./configuration.md#custom_dir -[name]: ./configuration.md#name -[docs_dir]:./configuration.md#docs_dir +[Customizing Your Theme]: ../user-guide/customizing-your-theme.md#using-the-theme-custom_dir +[custom_dir]: ../user-guide/configuration.md#custom_dir +[name]: ../user-guide/configuration.md#name +[docs_dir]: ../user-guide/configuration.md#docs_dir [configuration]: #theme-configuration [packaged]: #packaging-themes -[theme]: ./configuration.md#theme +[theme]: ../user-guide/configuration.md#theme ## Basic theme @@ -114,8 +117,8 @@ with one of the [built-in themes] and modify it accordingly. [Jinja]: http://jinja.pocoo.org/ [template inheritance]: http://jinja.pocoo.org/docs/dev/templates/#template-inheritance -[theme_dir]: ./styling-your-docs.md#using-the-theme_dir -[blocks]: ./styling-your-docs.md#overriding-template-blocks +[theme_dir]: ../user-guide/customizing-your-theme.md#using-the-theme_dir +[blocks]: ../user-guide/customizing-your-theme.md#overriding-template-blocks ## Theme Files @@ -177,16 +180,16 @@ The `config` variable is an instance of MkDocs' config object generated from the `mkdocs.yml` config file. While you can use any config option, some commonly used options include: -* [config.site_name](./configuration.md#site_name) -* [config.site_url](./configuration.md#site_url) -* [config.site_author](./configuration.md#site_author) -* [config.site_description](./configuration.md#site_description) -* [config.extra_javascript](./configuration.md#extra_javascript) -* [config.extra_css](./configuration.md#extra_css) -* [config.repo_url](./configuration.md#repo_url) -* [config.repo_name](./configuration.md#repo_name) -* [config.copyright](./configuration.md#copyright) -* [config.google_analytics](./configuration.md#google_analytics) +* [config.site_name](../user-guide/configuration.md#site_name) +* [config.site_url](../user-guide/configuration.md#site_url) +* [config.site_author](../user-guide/configuration.md#site_author) +* [config.site_description](../user-guide/configuration.md#site_description) +* [config.extra_javascript](../user-guide/configuration.md#extra_javascript) +* [config.extra_css](../user-guide/configuration.md#extra_css) +* [config.repo_url](../user-guide/configuration.md#repo_url) +* [config.repo_name](../user-guide/configuration.md#repo_name) +* [config.copyright](../user-guide/configuration.md#copyright) +* [config.google_analytics](../user-guide/configuration.md#google_analytics) #### nav @@ -194,7 +197,7 @@ The `nav` variable is used to create the navigation for the documentation. The `nav` object is an iterable of [navigation objects](#navigation-objects) as defined by the [nav] configuration setting. -[nav]: configuration.md#nav +[nav]: ../user-guide/configuration.md#nav In addition to the iterable of [navigation objects](#navigation-objects), the `nav` object contains the following attributes: @@ -357,7 +360,7 @@ For example, if `site_url: https://example.com/`, then the value of `site_url: https://example.com/bar/`, then the value of `page.abs_url` for the page `foo.md` would be `/bar/foo/`. -[site_url]: ./configuration.md#site_url +[site_url]: ../user-guide/configuration.md#site_url ##### page.canonical_url @@ -526,7 +529,7 @@ link objects. ### Extra Context Additional variables can be passed to the template with the -[`extra`](./configuration.md#extra) configuration option. This is a +[`extra`](../user-guide/configuration.md#extra) configuration option. This is a set of key value pairs that can make custom templates far more flexible. For example, this could be used to include the project version of all pages @@ -692,8 +695,8 @@ index when it is available. The `index` object was new in MkDocs version *1.0*. [built-in themes]: https://github.com/mkdocs/mkdocs/tree/master/mkdocs/themes [theme's configuration file]: #theme-configuration [lunr.js]: https://lunrjs.com/ -[site_dir]: configuration.md#site_dir -[prebuild_index]: configuration.md#prebuild_index +[site_dir]: ../user-guide/configuration.md#site_dir +[prebuild_index]: ../user-guide/configuration.md#prebuild_index ## Packaging Themes @@ -866,4 +869,4 @@ For a much more detailed guide, see the official Python packaging documentation for [Packaging and Distributing Projects]. [Packaging and Distributing Projects]: https://packaging.python.org/en/latest/distributing/ -[theme]: ./configuration.md#theme +[theme]: ../user-guide/configuration.md#theme diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 00000000..8e680e66 --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,209 @@ +# Getting Started with MkDocs + +An introductory tutorial! + +--- + +## Installation + +To install MkDocs, run the following command from the command line: + +```bash +pip install mkdocs +``` + +For more details, see the [Installation Guide]. + +## Creating a new project + +Getting started is super easy. To create a new project, run the following +command from the command line: + +```bash +mkdocs new my-project +cd my-project +``` + +Take a moment to review the initial project that has been created for you. + + + +There's a single configuration file named `mkdocs.yml`, and a folder named +`docs` that will contain your documentation source files (`docs` is +the default value for the [docs_dir] configuration setting). Right now the `docs` +folder just contains a single documentation page, named `index.md`. + +MkDocs comes with a built-in dev-server that lets you preview your documentation +as you work on it. Make sure you're in the same directory as the `mkdocs.yml` +configuration file, and then start the server by running the `mkdocs serve` +command: + +```bash +$ mkdocs serve +INFO - Building documentation... +INFO - Cleaning site directory +[I 160402 15:50:43 server:271] Serving on http://127.0.0.1:8000 +[I 160402 15:50:43 handlers:58] Start watching changes +[I 160402 15:50:43 handlers:60] Start detecting changes +``` + +Open up `http://127.0.0.1:8000/` in your browser, and you'll see the default +home page being displayed: + + + +The dev-server also supports auto-reloading, and will rebuild your documentation +whenever anything in the configuration file, documentation directory, or theme +directory changes. + +Open the `docs/index.md` document in your text editor of choice, change the +initial heading to `MkLorum`, and save your changes. Your browser will +auto-reload and you should see your updated documentation immediately. + +Now try editing the configuration file: `mkdocs.yml`. Change the +[`site_name`][site_name] setting to `MkLorum` and save the file. + +```yaml +site_name: MkLorum +``` + +Your browser should immediately reload, and you'll see your new site name take +effect. + + + +## Adding pages + +Now add a second page to your documentation: + +```bash +curl 'https://jaspervdj.be/lorem-markdownum/markdown.txt' > docs/about.md +``` + +As our documentation site will include some navigation headers, you may want to +edit the configuration file and add some information about the order, title, and +nesting of each page in the navigation header by adding a [`nav`][nav] +setting: + +```yaml +site_name: MkLorum +nav: + - Home: index.md + - About: about.md +``` + +Save your changes and you'll now see a navigation bar with `Home` and `About` +items on the left as well as `Search`, `Previous`, and `Next` items on the +right. + + + +Try the menu items and navigate back and forth between pages. Then click on +`Search`. A search dialog will appear, allowing you to search for any text on +any page. Notice that the search results include every occurrence of the search +term on the site and links directly to the section of the page in which the +search term appears. You get all of that with no effort or configuration on your +part! + + + +## Theming our documentation + +Now change the configuration file to alter how the documentation is displayed by +changing the theme. Edit the `mkdocs.yml` file and add a [`theme`][theme] setting: + +```yaml +site_name: MkLorum +nav: + - Home: index.md + - About: about.md +theme: readthedocs +``` + +Save your changes, and you'll see the ReadTheDocs theme being used. + + + +## Changing the Favicon Icon + +By default, MkDocs uses the [MkDocs favicon] icon. To use a different icon, create +an `img` subdirectory in the `docs` directory and copy your custom `favicon.ico` +file to that directory. MkDocs will automatically detect and use that file as your +favicon icon. + +[MkDocs favicon]: img/favicon.ico + +## Building the site + +That's looking good. You're ready to deploy the first pass of your `MkLorum` +documentation. First build the documentation: + +```bash +mkdocs build +``` + +This will create a new directory, named `site`. Take a look inside the +directory: + +```bash +$ ls site +about fonts index.html license search.html +css img js mkdocs sitemap.xml +``` + +Notice that your source documentation has been output as two HTML files named +`index.html` and `about/index.html`. You also have various other media that's +been copied into the `site` directory as part of the documentation theme. You +even have a `sitemap.xml` file and `mkdocs/search_index.json`. + +If you're using source code control such as `git` you probably don't want to +check your documentation builds into the repository. Add a line containing +`site/` to your `.gitignore` file. + +```bash +echo "site/" >> .gitignore +``` + +If you're using another source code control tool you'll want to check its +documentation on how to ignore specific directories. + +## Other Commands and Options + +There are various other commands and options available. For a complete list of +commands, use the `--help` flag: + +```bash +mkdocs --help +``` + +To view a list of options available on a given command, use the `--help` flag +with that command. For example, to get a list of all options available for the +`build` command run the following: + +```bash +mkdocs build --help +``` + +## Deploying + +The documentation site that you just built only uses static files so you'll be +able to host it from pretty much anywhere. Simply upload the contents of the +entire `site` directory to wherever you're hosting your website from and +you're done. For specific instructions on a number of common hosts, see the +[Deploying your Docs][deploy] page. + +## Getting help + +See the [User Guide] for more complete documentation of all of MkDocs' features. + +To get help with MkDocs, please use the [GitHub discussions] or [GitHub issues]. + +[Installation Guide]: user-guide/installation.md +[docs_dir]: user-guide/configuration.md#docs_dir +[deploy]: user-guide/deploying-your-docs.md +[nav]: user-guide/configuration.md#nav +[GitHub discussions]: https://github.com/mkdocs/mkdocs/discussions +[GitHub issues]: https://github.com/mkdocs/mkdocs/issues +[site_name]: user-guide/configuration.md#site_name +[theme]: user-guide/configuration.md#theme +[User Guide]: user-guide/index.md diff --git a/docs/index.md b/docs/index.md index 0c4279a5..43cebdb0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,360 +4,86 @@ Project documentation with Markdown. --- -## Overview - MkDocs is a **fast**, **simple** and **downright gorgeous** static site generator that's geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML -configuration file. Start by reading the introduction below, then check the User -Guide for more info. - -### Host anywhere - -MkDocs builds completely static HTML sites that you can host on GitHub pages, -Amazon S3, or [anywhere][deploy] else you choose. - -### Great themes available - -There's a stack of good looking [themes] available for MkDocs. Choose between -the built in themes: [mkdocs] and [readthedocs], select one of the 3rd -party themes listed on the [MkDocs Themes] wiki page, or [build your own]. - -### Preview your site as you work - -The built-in dev-server allows you to preview your documentation as you're -writing it. It will even auto-reload and refresh your browser whenever you save -your changes. - -### Easy to customize - -Get your project documentation looking just the way you want it by customizing -the [theme] and/or installing some [plugins]. - ---- - -## Installation - -### Install with a Package Manager - -If you have and use a package manager (such as [apt-get], [dnf], [homebrew], -[yum], [chocolatey], etc.) to install packages on your system, then you may -want to search for a "MkDocs" package and, if a recent version is available, -install it with your package manager (check your system's documentation for -details). That's it, you're done! Skip down to [Getting Started](#getting-started). - -If your package manager does not have a recent "MkDocs" package, you can still -use your package manager to install "Python" and "pip". Then you can use pip to -[install MkDocs](#installing-mkdocs). - -[apt-get]: https://help.ubuntu.com/community/AptGet/Howto -[homebrew]: https://brew.sh/ -[dnf]: https://dnf.readthedocs.io/en/latest/index.html -[yum]: http://yum.baseurl.org/ -[chocolatey]: https://chocolatey.org/ - -### Manual Installation - -In order to manually install MkDocs you'll need [Python] installed on your -system, as well as the Python package manager, [pip]. You can check if you have -these already installed from the command line: - -```bash -$ python --version -Python 3.8.2 -$ pip --version -pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) -``` - -MkDocs supports Python versions 3.5, 3.6, 3.7, 3.8, and pypy3. - -#### Installing Python - -Install [Python] by downloading an installer appropriate for your system from -[python.org] and running it. - -!!! Note - - If you are installing Python on Windows, be sure to check the box to have - Python added to your PATH if the installer offers such an option (it's - normally off by default). - -  - -[python.org]: https://www.python.org/downloads/ - -#### Installing pip - -If you're using a recent version of Python, the Python package manager, [pip], -is most likely installed by default. However, you may need to upgrade pip to the -lasted version: - -```bash -pip install --upgrade pip -``` - -If you need to install [pip] for the first time, download [get-pip.py]. -Then run the following command to install it: - -```bash -python get-pip.py -``` - -#### Installing MkDocs - -Install the `mkdocs` package using pip: - -```bash -pip install mkdocs -``` - -You should now have the `mkdocs` command installed on your system. Run `mkdocs ---version` to check that everything worked okay. - -```bash -$ mkdocs --version -mkdocs, version 0.15.3 -``` - -!!! Note - If you would like manpages installed for MkDocs, the [click-man] tool can - generate and install them for you. Simply run the following two commands: - - pip install click-man - click-man --target path/to/man/pages mkdocs - - See the [click-man documentation] for an explanation of why manpages are - not automatically generated and installed by pip. - -[click-man]: https://github.com/click-contrib/click-man -[click-man documentation]: https://github.com/click-contrib/click-man#automatic-man-page-installation-with-setuptools-and-pip - -!!! Note - If you are using Windows, some of the above commands may not work - out-of-the-box. - - A quick solution may be to preface every Python command with `python -m` - like this: - - python -m pip install mkdocs - python -m mkdocs - - For a more permanent solution, you may need to edit your `PATH` environment - variable to include the `Scripts` directory of your Python installation. - Recent versions of Python include a script to do this for you. Navigate to - your Python installation directory (for example `C:\Python38\`), open the - `Tools`, then `Scripts` folder, and run the `win_add2path.py` file by double - clicking on it. Alternatively, you can [download][a2p] the script and run it - (`python win_add2path.py`). - -[a2p]: https://svn.python.org/projects/python/trunk/Tools/scripts/win_add2path.py - ---- - -## Getting Started - -Getting started is super easy. - -```bash -mkdocs new my-project -cd my-project -``` - -Take a moment to review the initial project that has been created for you. - - - -There's a single configuration file named `mkdocs.yml`, and a folder named -`docs` that will contain your documentation source files (`docs` is -the default value for the [docs_dir] configuration setting). Right now the `docs` -folder just contains a single documentation page, named `index.md`. - -[docs_dir]: https://www.mkdocs.org/user-guide/configuration/#docs_dir - -MkDocs comes with a built-in dev-server that lets you preview your documentation -as you work on it. Make sure you're in the same directory as the `mkdocs.yml` -configuration file, and then start the server by running the `mkdocs serve` -command: - -```bash -$ mkdocs serve -INFO - Building documentation... -INFO - Cleaning site directory -[I 160402 15:50:43 server:271] Serving on http://127.0.0.1:8000 -[I 160402 15:50:43 handlers:58] Start watching changes -[I 160402 15:50:43 handlers:60] Start detecting changes -``` - -Open up `http://127.0.0.1:8000/` in your browser, and you'll see the default -home page being displayed: - - - -The dev-server also supports auto-reloading, and will rebuild your documentation -whenever anything in the configuration file, documentation directory, or theme -directory changes. - -Open the `docs/index.md` document in your text editor of choice, change the -initial heading to `MkLorum`, and save your changes. Your browser will -auto-reload and you should see your updated documentation immediately. - -Now try editing the configuration file: `mkdocs.yml`. Change the -[`site_name`][site_name] setting to `MkLorum` and save the file. - -```yaml -site_name: MkLorum -``` - -Your browser should immediately reload, and you'll see your new site name take -effect. - - - -## Adding pages - -Now add a second page to your documentation: - -```bash -curl 'https://jaspervdj.be/lorem-markdownum/markdown.txt' > docs/about.md -``` - -As our documentation site will include some navigation headers, you may want to -edit the configuration file and add some information about the order, title, and -nesting of each page in the navigation header by adding a [`nav`][nav] -setting: - -```yaml -site_name: MkLorum -nav: - - Home: index.md - - About: about.md -``` - -Save your changes and you'll now see a navigation bar with `Home` and `About` -items on the left as well as `Search`, `Previous`, and `Next` items on the -right. - - - -Try the menu items and navigate back and forth between pages. Then click on -`Search`. A search dialog will appear, allowing you to search for any text on -any page. Notice that the search results include every occurrence of the search -term on the site and links directly to the section of the page in which the -search term appears. You get all of that with no effort or configuration on your -part! - - - -## Theming our documentation - -Now change the configuration file to alter how the documentation is displayed by -changing the theme. Edit the `mkdocs.yml` file and add a [`theme`][theme] setting: - -```yaml -site_name: MkLorum -nav: - - Home: index.md - - About: about.md -theme: readthedocs -``` - -Save your changes, and you'll see the ReadTheDocs theme being used. - - - -## Changing the Favicon Icon - -By default, MkDocs uses the [MkDocs favicon] icon. To use a different icon, create -an `img` subdirectory in the `docs` directory and copy your custom `favicon.ico` -file to that directory. MkDocs will automatically detect and use that file as your -favicon icon. - -[MkDocs favicon]: /img/favicon.ico - -## Building the site - -That's looking good. You're ready to deploy the first pass of your `MkLorum` -documentation. First build the documentation: - -```bash -mkdocs build -``` - -This will create a new directory, named `site`. Take a look inside the -directory: - -```bash -$ ls site -about fonts index.html license search.html -css img js mkdocs sitemap.xml -``` - -Notice that your source documentation has been output as two HTML files named -`index.html` and `about/index.html`. You also have various other media that's -been copied into the `site` directory as part of the documentation theme. You -even have a `sitemap.xml` file and `mkdocs/search_index.json`. - -If you're using source code control such as `git` you probably don't want to -check your documentation builds into the repository. Add a line containing -`site/` to your `.gitignore` file. - -```bash -echo "site/" >> .gitignore -``` - -If you're using another source code control tool you'll want to check its -documentation on how to ignore specific directories. - -After some time, files may be removed from the documentation but they will still -reside in the `site` directory. To remove those stale files, just run `mkdocs` -with the `--clean` switch. - -```bash -mkdocs build --clean -``` - -## Other Commands and Options - -There are various other commands and options available. For a complete list of -commands, use the `--help` flag: - -```bash -mkdocs --help -``` - -To view a list of options available on a given command, use the `--help` flag -with that command. For example, to get a list of all options available for the -`build` command run the following: - -```bash -mkdocs build --help -``` - -## Deploying - -The documentation site that you just built only uses static files so you'll be -able to host it from pretty much anywhere. Simply upload the contents of the -entire `site` directory to wherever you're hosting your website from and -you're done. For specific instructions on a number of common hosts, see the -[Deploying your Docs][deploy] page. - -## Getting help - -To get help with MkDocs, please use the [GitHub discussions] or [GitHub issues]. - -[deploy]: user-guide/deploying-your-docs/ -[mkdocs]: user-guide/styling-your-docs/#mkdocs -[readthedocs]: user-guide/styling-your-docs/#readthedocs -[theme]: user-guide/styling-your-docs/ -[themes]: user-guide/styling-your-docs/ -[plugins]: user-guide/plugins/ -[MkDocs Themes]: https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes -[build your own]: user-guide/custom-themes/ -[get-pip.py]: https://bootstrap.pypa.io/get-pip.py -[nav]: user-guide/configuration/#nav -[GitHub discussions]: https://github.com/mkdocs/mkdocs/discussions -[GitHub issues]: https://github.com/mkdocs/mkdocs/issues -[pip]: https://pip.readthedocs.io/en/stable/installing/ -[Python]: https://www.python.org/ -[site_name]: user-guide/configuration/#site_name -[theme]: user-guide/configuration/#theme +configuration file. Start by reading the [introductory tutorial], then check the +[User Guide] for more information. + +[introductory tutorial]: getting-started.md +[User Guide]: user-guide/index.md + +
+ ++ There's a stack of good looking themes available for + MkDocs. Choose between the built in themes: mkdocs and readthedocs, + select one of the third-party themes listed on the MkDocs Themes wiki page, or build your + own. +
++ Get your project documentation looking just the way you want it by + customizing your + theme and/or installing some plugins. Modify + Markdown's behavior with Markdown + extensions. Many configuration options are + available. +
++ The built-in dev-server allows you to preview your documentation + as you're writing it. It will even auto-reload and refresh your + browser whenever you save your changes. +
++ MkDocs builds completely static HTML sites that you can host on + GitHub pages, Amazon S3, or anywhere else you + choose. +
+