MkDocs basic usage
Filesystem startup
For a MkDocs ‘project’ on something called Subject, the factory default filesystem starts out like this:
Subject/
├─ docs/
│ └─ index.md
└─ mkdocs.yml
The top-level Subject directory would be created manually by an operator, and mkdocs new then pointed to it in a command like...
mkdocs new /path/to/Subject
The docs subdirectory and the mkdocs.yml and index.md files would get synthesized in the new operation.
Rendering
From the input ‘configuration and content’, comprised of the mkdocs.yml file and – more substantially – the .md files below the docs subdirectory, an HTML representation can be derived using the...
mkdocs build
...command. The rendering process writes into a site directory, which by default is located alongside docs/ and mkdocs.yml. Resulting, after the first time a build operation has taken place, in the following extended filesystem layout:
Subject/
├─ docs/
│ └─ index.md
├─ site/
│ └─ ...
└─ mkdocs.yml
The site subdirectory will contain HTML files and related materials that can be consumed by a web browser.
The contents of site/ is what a web server would be expecting to find in its filesystem-local document root location – on RHEL that is /var/www/html/.
Located within the site subdirectory is an index.html file that may also be opened locally, in a copy of a web browser that can access the filesystem on which site/ is located.
MkDocs’ build process runs in online mode by default. This results in references from one part of the rendered site to another to be abbreviated, ‘beautified’ to some extent.
In offline mode, references contain concrete target files rather than just the path to their parent directory – which filesystem-accessing browsers tend to dislike.
Offline mode can be enabled with a plugin clause in the mkdocs.yml file. To mkdocs build there are also command line options --directory-urls and --no-directory-urls, with the former the default.
Unlike mkdocs new, the build flavor of mkdocs cannot be directly aimed at a project directory. A command line option -f/--config-filedoes exist, for mkdocs build. This allows operators to reference the mkdocs.yml file that is located within a project directory.
For having the rendered content placed elsewhere, mkdocs build has a -d/--site-dir option.
Live viewing
mkdocs has a serve mode that can be pointed at a MkDocs project in the same way the build mode can.
In serve mode, MkDocs spins up an embedded web server through which rendered content can be viewed remotely.
When any change is made to the source content within the project directory, the site content is re-rendered on the fly and any browser that may be looking at it refreshed automatically.