2020-07-16 23:31:39 +03:00
|
|
|
# Customization
|
|
|
|
|
|
|
|
Project documentation is as diverse as the projects themselves and Material for
|
2020-08-30 18:37:49 +03:00
|
|
|
MkDocs is a great starting point for making it look beautiful. However, as you
|
|
|
|
write your documentation, you may reach a point where small adjustments are
|
2020-07-16 23:31:39 +03:00
|
|
|
necessary to preserve your brand's style.
|
|
|
|
|
|
|
|
## Adding assets
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[MkDocs] provides several ways to customize a theme. In order to make a few
|
2021-11-29 20:35:58 +03:00
|
|
|
small tweaks to Material for MkDocs, you can just add CSS and JavaScript files to
|
2021-10-10 23:32:32 +03:00
|
|
|
the `docs` directory.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[MkDocs]: https://www.mkdocs.org
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-09-19 15:34:40 +03:00
|
|
|
### Additional CSS
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
If you want to tweak some colors or change the spacing of certain elements,
|
2021-12-10 12:12:07 +03:00
|
|
|
you can do this in a separate style sheet. The easiest way is by creating a
|
|
|
|
new style sheet file in the `docs` directory:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2022-12-31 17:02:02 +03:00
|
|
|
``` { .sh .no-copy }
|
2020-08-30 18:37:49 +03:00
|
|
|
.
|
|
|
|
├─ docs/
|
|
|
|
│ └─ stylesheets/
|
|
|
|
│ └─ extra.css
|
|
|
|
└─ mkdocs.yml
|
2020-07-16 23:31:39 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Then, add the following lines to `mkdocs.yml`:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
extra_css:
|
|
|
|
- stylesheets/extra.css
|
|
|
|
```
|
|
|
|
|
|
|
|
### Additional JavaScript
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
If you want to integrate another syntax highlighter or add some custom logic to
|
|
|
|
your theme, create a new JavaScript file in the `docs` directory:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2022-12-31 17:02:02 +03:00
|
|
|
``` { .sh .no-copy }
|
2020-08-30 18:37:49 +03:00
|
|
|
.
|
|
|
|
├─ docs/
|
|
|
|
│ └─ javascripts/
|
|
|
|
│ └─ extra.js
|
|
|
|
└─ mkdocs.yml
|
2020-07-16 23:31:39 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Then, add the following lines to `mkdocs.yml`:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
extra_javascript:
|
|
|
|
- javascripts/extra.js
|
|
|
|
```
|
|
|
|
|
2023-10-16 19:35:09 +03:00
|
|
|
??? tip "How to integrate with third-party JavaScript libraries"
|
2023-10-16 17:25:29 +03:00
|
|
|
|
|
|
|
It is likely that you will want to run your JavaScript code only
|
|
|
|
once the page has been fully loaded by the browser. This means
|
|
|
|
installing a callback function subscribing to events on the
|
|
|
|
`document$` observable exported by Material for MkDocs.
|
|
|
|
Using the `document$` observable is particularly important if you
|
|
|
|
are using [instant loading] since it will not result in a page
|
|
|
|
refresh in the browser - but subscribers on the observable will be
|
|
|
|
notified.
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
document$.subscribe(function() {
|
2023-10-16 19:36:10 +03:00
|
|
|
console.log("Initialize third-party libraries here")
|
2023-10-16 17:25:29 +03:00
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
`document$` is an [RxJS Observable] and you can call the `subscribe()`
|
|
|
|
method any number of times to attach different functionality.
|
|
|
|
|
2023-10-16 19:35:09 +03:00
|
|
|
[instant loading]: setup/setting-up-navigation.md/#instant-loading
|
|
|
|
[RxJS Observable]: https://rxjs.dev/api/index/class/Observable
|
2023-10-16 17:25:29 +03:00
|
|
|
|
2020-07-16 23:31:39 +03:00
|
|
|
## Extending the theme
|
|
|
|
|
2020-08-30 18:37:49 +03:00
|
|
|
If you want to alter the HTML source (e.g. add or remove some parts), you can
|
2021-10-10 23:32:32 +03:00
|
|
|
extend the theme. MkDocs supports [theme extension], an easy way to override
|
2020-08-30 18:37:49 +03:00
|
|
|
parts of Material for MkDocs without forking from git. This ensures that you
|
|
|
|
can update to the latest version more easily.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2024-03-06 03:23:30 +03:00
|
|
|
[theme extension]: https://www.mkdocs.org/user-guide/customizing-your-theme/#using-the-theme-custom_dir
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
### Setup and theme structure
|
|
|
|
|
2020-08-30 18:37:49 +03:00
|
|
|
Enable Material for MkDocs as usual in `mkdocs.yml`, and create a new folder
|
2021-10-10 23:32:32 +03:00
|
|
|
for `overrides` which you then reference using the [`custom_dir`][custom_dir]
|
|
|
|
setting:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
theme:
|
|
|
|
name: material
|
|
|
|
custom_dir: overrides
|
|
|
|
```
|
|
|
|
|
|
|
|
!!! warning "Theme extension prerequisites"
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
As the [`custom_dir`][custom_dir] setting is used for the theme extension
|
|
|
|
process, Material for MkDocs needs to be installed via `pip` and referenced
|
|
|
|
with the [`name`][name] setting in `mkdocs.yml`. It will not work when
|
|
|
|
cloning from `git`.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
The structure in the `overrides` directory must mirror the directory structure
|
|
|
|
of the original theme, as any file in the `overrides` directory will replace the
|
|
|
|
file with the same name which is part of the original theme. Besides, further
|
2021-10-10 23:32:32 +03:00
|
|
|
assets may also be put in the `overrides` directory:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2022-12-31 17:02:02 +03:00
|
|
|
``` { .sh .no-copy }
|
2020-07-16 23:31:39 +03:00
|
|
|
.
|
2020-07-22 12:57:41 +03:00
|
|
|
├─ .icons/ # Bundled icon sets
|
2020-07-16 23:31:39 +03:00
|
|
|
├─ assets/
|
|
|
|
│ ├─ images/ # Images and icons
|
2021-10-30 14:49:01 +03:00
|
|
|
│ ├─ javascripts/ # JavaScript files
|
2021-11-28 18:58:52 +03:00
|
|
|
│ └─ stylesheets/ # Style sheets
|
2020-07-16 23:31:39 +03:00
|
|
|
├─ partials/
|
2020-07-20 16:18:09 +03:00
|
|
|
│ ├─ integrations/ # Third-party integrations
|
2021-10-30 14:49:01 +03:00
|
|
|
│ │ ├─ analytics/ # Analytics integrations
|
2021-11-13 15:15:58 +03:00
|
|
|
│ │ └─ analytics.html # Analytics setup
|
2021-10-30 14:49:01 +03:00
|
|
|
│ ├─ languages/ # Translation languages
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ actions.html # Actions
|
2023-08-21 19:14:08 +03:00
|
|
|
│ ├─ alternate.html # Site language selector
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ comments.html # Comment system (empty by default)
|
|
|
|
│ ├─ consent.html # Consent
|
2021-11-14 10:46:35 +03:00
|
|
|
│ ├─ content.html # Page content
|
2021-11-13 16:23:10 +03:00
|
|
|
│ ├─ copyright.html # Copyright and theme information
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ feedback.html # Was this page helpful?
|
2020-07-16 23:31:39 +03:00
|
|
|
│ ├─ footer.html # Footer bar
|
|
|
|
│ ├─ header.html # Header bar
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ icons.html # Custom icons
|
2021-10-30 14:49:01 +03:00
|
|
|
│ ├─ language.html # Translation setup
|
2020-07-16 23:31:39 +03:00
|
|
|
│ ├─ logo.html # Logo in header and sidebar
|
|
|
|
│ ├─ nav.html # Main navigation
|
|
|
|
│ ├─ nav-item.html # Main navigation item
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ pagination.html # Pagination (used for blog)
|
2023-08-21 19:08:46 +03:00
|
|
|
│ ├─ palette.html # Color palette toggle
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ post.html # Blog post excerpt
|
2023-10-01 10:45:58 +03:00
|
|
|
│ ├─ progress.html # Progress indicator
|
2021-11-13 16:23:10 +03:00
|
|
|
│ ├─ search.html # Search interface
|
2020-07-16 23:31:39 +03:00
|
|
|
│ ├─ social.html # Social links
|
|
|
|
│ ├─ source.html # Repository information
|
2021-10-10 23:32:32 +03:00
|
|
|
│ ├─ source-file.html # Source file information
|
2020-07-16 23:31:39 +03:00
|
|
|
│ ├─ tabs.html # Tabs navigation
|
|
|
|
│ ├─ tabs-item.html # Tabs navigation item
|
2022-09-11 20:25:40 +03:00
|
|
|
│ ├─ tags.html # Tags
|
2020-07-16 23:31:39 +03:00
|
|
|
│ ├─ toc.html # Table of contents
|
2023-10-01 10:45:58 +03:00
|
|
|
│ ├─ toc-item.html # Table of contents item
|
|
|
|
│ └─ top.html # Back-to-top button
|
2020-07-16 23:31:39 +03:00
|
|
|
├─ 404.html # 404 error page
|
|
|
|
├─ base.html # Base template
|
2022-09-12 10:42:53 +03:00
|
|
|
├─ blog.html # Blog index page
|
|
|
|
├─ blog-archive.html # Blog archive index page
|
|
|
|
├─ blog-category.html # Blog category index page
|
|
|
|
├─ blog-post.html # Blog post page
|
|
|
|
└─ main.html # Default page
|
2020-07-16 23:31:39 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[custom_dir]: https://www.mkdocs.org/user-guide/configuration/#custom_dir
|
|
|
|
[name]: https://www.mkdocs.org/user-guide/configuration/#name
|
|
|
|
|
2020-07-16 23:31:39 +03:00
|
|
|
### Overriding partials
|
|
|
|
|
2020-08-30 18:37:49 +03:00
|
|
|
In order to override a partial, we can replace it with a file of the same name
|
2020-12-08 01:24:20 +03:00
|
|
|
and location in the `overrides` directory. For example, to replace the original
|
2021-10-10 23:32:32 +03:00
|
|
|
`footer.html` partial, create a new `footer.html` partial in the `overrides`
|
2020-08-30 18:37:49 +03:00
|
|
|
directory:
|
|
|
|
|
2022-12-31 17:02:02 +03:00
|
|
|
``` { .sh .no-copy }
|
2020-08-30 18:37:49 +03:00
|
|
|
.
|
|
|
|
├─ overrides/
|
|
|
|
│ └─ partials/
|
|
|
|
│ └─ footer.html
|
|
|
|
└─ mkdocs.yml
|
|
|
|
```
|
|
|
|
|
|
|
|
MkDocs will now use the new partial when rendering the theme. This can be done
|
|
|
|
with any file.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
### Overriding blocks <small>recommended</small> { #overriding-blocks data-toc-label="Overriding blocks" }
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-08-30 18:37:49 +03:00
|
|
|
Besides overriding partials, it's also possible to override (and extend)
|
2021-10-10 23:32:32 +03:00
|
|
|
template blocks, which are defined inside the templates and wrap specific
|
|
|
|
features. In order to set up block overrides, create a `main.html` file inside
|
|
|
|
the `overrides` directory:
|
2020-08-30 18:37:49 +03:00
|
|
|
|
2022-12-31 17:02:02 +03:00
|
|
|
``` { .sh .no-copy }
|
2020-08-30 18:37:49 +03:00
|
|
|
.
|
|
|
|
├─ overrides/
|
|
|
|
│ └─ main.html
|
|
|
|
└─ mkdocs.yml
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Then, e.g. to override the site title, add the following lines to `main.html`:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-07-27 15:44:47 +03:00
|
|
|
``` html
|
2020-07-16 23:31:39 +03:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block htmltitle %}
|
|
|
|
<title>Lorem ipsum dolor sit amet</title>
|
|
|
|
{% endblock %}
|
|
|
|
```
|
2022-09-11 17:44:06 +03:00
|
|
|
|
2022-09-11 17:49:28 +03:00
|
|
|
If you intend to __add__ something to a block rather than to replace it
|
2023-10-01 10:45:58 +03:00
|
|
|
altogether with new content, use `{{ super() }}` inside the block to include the
|
2022-09-11 17:49:28 +03:00
|
|
|
original block content. This is particularly useful when adding third-party
|
|
|
|
scripts to your docs, e.g.
|
2022-09-11 17:44:06 +03:00
|
|
|
|
2022-09-11 17:49:28 +03:00
|
|
|
``` html
|
2022-09-11 17:44:06 +03:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block scripts %}
|
2022-09-11 17:49:28 +03:00
|
|
|
<!-- Add scripts that need to run before here -->
|
|
|
|
{{ super() }}
|
|
|
|
<!-- Add scripts that need to run afterwards here -->
|
2022-09-11 17:44:06 +03:00
|
|
|
{% endblock %}
|
2022-09-11 17:49:28 +03:00
|
|
|
```
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
The following template blocks are provided by the theme:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-04-10 12:13:32 +03:00
|
|
|
| Block name | Purpose |
|
2021-11-30 21:33:13 +03:00
|
|
|
| :---------------- | :---------------------------------------------- |
|
2021-03-01 00:40:01 +03:00
|
|
|
| `analytics` | Wraps the Google Analytics integration |
|
|
|
|
| `announce` | Wraps the announcement bar |
|
|
|
|
| `config` | Wraps the JavaScript application config |
|
2022-09-11 20:25:40 +03:00
|
|
|
| `container` | Wraps the main content container |
|
2021-03-01 00:40:01 +03:00
|
|
|
| `content` | Wraps the main content |
|
|
|
|
| `extrahead` | Empty block to add custom meta tags |
|
|
|
|
| `fonts` | Wraps the font definitions |
|
|
|
|
| `footer` | Wraps the footer with navigation and copyright |
|
|
|
|
| `header` | Wraps the fixed header bar |
|
|
|
|
| `hero` | Wraps the hero teaser (if available) |
|
|
|
|
| `htmltitle` | Wraps the `<title>` tag |
|
|
|
|
| `libs` | Wraps the JavaScript libraries (header) |
|
2021-03-28 20:46:59 +03:00
|
|
|
| `outdated` | Wraps the version warning |
|
2021-03-01 00:40:01 +03:00
|
|
|
| `scripts` | Wraps the JavaScript application (footer) |
|
|
|
|
| `site_meta` | Wraps the meta tags in the document head |
|
|
|
|
| `site_nav` | Wraps the site navigation and table of contents |
|
2021-10-10 23:32:32 +03:00
|
|
|
| `styles` | Wraps the style sheets (also extra sources) |
|
2021-03-01 00:40:01 +03:00
|
|
|
| `tabs` | Wraps the tabs navigation (if available) |
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
## Theme development
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Material for MkDocs is built on top of [TypeScript], [RxJS] and [SASS], and
|
|
|
|
uses a lean, custom build process to put everything together.[^1] If you want
|
|
|
|
to make more fundamental changes, it may be necessary to make the adjustments
|
|
|
|
directly in the source of the theme and recompile it.
|
2021-02-26 18:41:00 +03:00
|
|
|
|
|
|
|
[^1]:
|
2023-09-14 20:09:18 +03:00
|
|
|
Prior to <!-- md:version 7.0.0 --> the build was based on Webpack, resulting
|
2021-10-10 23:32:32 +03:00
|
|
|
in occasional broken builds due to incompatibilities with loaders and
|
|
|
|
plugins. Therefore, we decided to swap Webpack for a leaner solution which
|
|
|
|
is now based on [RxJS] as the application itself. This allowed for the
|
|
|
|
pruning of more than 500 dependencies (~30% less).
|
2021-02-26 18:41:00 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[TypeScript]: https://www.typescriptlang.org/
|
|
|
|
[RxJS]: https://github.com/ReactiveX/rxjs
|
|
|
|
[SASS]: https://sass-lang.com
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
### Environment setup
|
|
|
|
|
2023-10-03 18:33:25 +03:00
|
|
|
First, clone the repository for the edition you want to work on. If
|
|
|
|
you want to clone the Insiders repository, you need to become a
|
|
|
|
sponsor first to gain access.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2023-10-03 18:33:25 +03:00
|
|
|
[Insiders]: insiders/index.md
|
|
|
|
|
|
|
|
=== "Material for MkDocs"
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone https://github.com/squidfunk/mkdocs-material
|
|
|
|
cd mkdocs-material
|
|
|
|
```
|
|
|
|
|
|
|
|
=== "Insiders"
|
|
|
|
|
|
|
|
You will need to have a GitHub access token [as described in the
|
2023-10-16 17:25:29 +03:00
|
|
|
Insiders documentation] and make it available in the `$GH_TOKEN`
|
|
|
|
variable.
|
2023-10-03 18:33:25 +03:00
|
|
|
|
|
|
|
``` sh
|
|
|
|
git clone https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git # (1)!
|
|
|
|
```
|
|
|
|
|
|
|
|
1. If you are using SSH keys for authenticating with GitHub, you can
|
|
|
|
clone Insiders with this command:
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone git@github.com:squidfunk/mkdocs-material-insiders.git
|
|
|
|
```
|
|
|
|
|
|
|
|
[as described in the Insiders documentation]: insiders/getting-started.md#requirements
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2023-08-21 19:18:21 +03:00
|
|
|
Next, create a new [Python virtual environment][venv] and
|
|
|
|
[activate][venv-activate] it:
|
|
|
|
|
|
|
|
```
|
2023-08-29 21:22:05 +03:00
|
|
|
python -m venv venv
|
|
|
|
source venv/bin/activate
|
2023-08-21 19:18:21 +03:00
|
|
|
```
|
|
|
|
|
2023-10-03 18:33:25 +03:00
|
|
|
!!! note "Ensure pip always runs in a virtual environment"
|
|
|
|
|
|
|
|
If you set the environment variable `PIP_REQUIRE_VIRTUALENV` to
|
|
|
|
`true`, `pip` will refuse to install anything outside a virtual
|
|
|
|
environment. Forgetting to activate a `venv` can be very annoying
|
|
|
|
as it will install all sorts of things outside virtual
|
2023-10-16 17:25:29 +03:00
|
|
|
environments over time, possibly leading to further errors. So,
|
2023-10-03 18:33:25 +03:00
|
|
|
you may want to add this to your `.bashrc` or `.zshrc` and
|
|
|
|
re-start your shell:
|
|
|
|
|
|
|
|
```
|
|
|
|
export PIP_REQUIRE_VIRTUALENV=true
|
|
|
|
```
|
|
|
|
|
2023-08-21 19:18:21 +03:00
|
|
|
[venv]: https://docs.python.org/3/library/venv.html
|
|
|
|
[venv-activate]: https://docs.python.org/3/library/venv.html#how-venvs-work
|
|
|
|
|
|
|
|
Then, install all Python dependencies:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2023-10-03 18:33:25 +03:00
|
|
|
=== "Material for MkDocs"
|
|
|
|
|
|
|
|
```
|
2023-10-14 10:09:13 +03:00
|
|
|
pip install -e ".[recommended]"
|
2023-10-03 18:33:25 +03:00
|
|
|
pip install nodeenv
|
|
|
|
```
|
|
|
|
|
|
|
|
=== "Insiders"
|
|
|
|
|
|
|
|
```
|
2023-10-14 10:09:13 +03:00
|
|
|
pip install -e ".[recommended, imaging]"
|
2023-10-03 18:33:25 +03:00
|
|
|
pip install nodeenv
|
|
|
|
```
|
|
|
|
|
|
|
|
In addition, you will need to install the `cairo` and `pngquant` libraries in your
|
|
|
|
system, as described in the [image processing] requirements guide.
|
|
|
|
|
|
|
|
[image processing]: plugins/requirements/image-processing.md
|
|
|
|
|
2023-08-21 19:18:21 +03:00
|
|
|
|
|
|
|
Finally, install the [Node.js] LTS version into the Python virtual environment
|
|
|
|
and install all Node.js dependencies:
|
|
|
|
|
|
|
|
```
|
2023-08-29 21:23:58 +03:00
|
|
|
nodeenv -p -n lts
|
2020-07-16 23:31:39 +03:00
|
|
|
npm install
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[Node.js]: https://nodejs.org
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
### Development mode
|
|
|
|
|
2021-02-23 01:28:43 +03:00
|
|
|
Start the watcher with:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-07-23 15:37:20 +03:00
|
|
|
```
|
2020-07-16 23:31:39 +03:00
|
|
|
npm start
|
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Then, in a second terminal window, start the MkDocs live preview server with:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-07-23 15:37:20 +03:00
|
|
|
```
|
2021-10-30 14:29:35 +03:00
|
|
|
mkdocs serve --watch-theme
|
2020-07-16 23:31:39 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
Point your browser to [localhost:8000][live preview] and you should see this
|
|
|
|
very documentation in front of you.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
!!! warning "Automatically generated files"
|
|
|
|
|
|
|
|
Never make any changes in the `material` directory, as the contents of this
|
|
|
|
directory are automatically generated from the `src` directory and will be
|
2021-06-12 14:29:20 +03:00
|
|
|
overwritten when the theme is built.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
[live preview]: http://localhost:8000
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2020-07-17 14:08:27 +03:00
|
|
|
### Building the theme
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
When you're finished making your changes, you can build the theme by invoking:
|
|
|
|
|
2022-04-10 00:33:08 +03:00
|
|
|
``` sh
|
|
|
|
npm run build # (1)!
|
2020-07-23 15:37:20 +03:00
|
|
|
```
|
2022-04-10 00:33:08 +03:00
|
|
|
|
|
|
|
1. While this command will build all theme files, it will skip the overrides
|
|
|
|
used in Material for MkDocs' own documentation which are not distributed
|
|
|
|
with the theme. If you forked the theme and want to build the overrides
|
2023-08-29 21:26:49 +03:00
|
|
|
as well, e.g. before submitting a PR with changes, use:
|
2022-04-10 00:33:08 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
npm run build:all
|
|
|
|
```
|
|
|
|
|
|
|
|
This will take longer, as now the icon search index, schema files, as
|
|
|
|
well as additional style sheet and JavaScript files are built.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
2021-10-10 23:32:32 +03:00
|
|
|
This triggers the production-level compilation and minification of all style
|
|
|
|
sheets and JavaScript files. After the command exits, the compiled files are
|
|
|
|
located in the `material` directory. When running `mkdocs build`, you should
|
|
|
|
now see your changes to the original theme.
|