2020-07-22 14:37:14 +03:00
|
|
|
---
|
|
|
|
template: overrides/main.html
|
|
|
|
---
|
|
|
|
|
2020-07-22 12:57:41 +03:00
|
|
|
# Adding a comment system
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
Material for MkDocs is natively integrated with [Disqus], a comment system that
|
|
|
|
provides a wide range of features like social integrations, user profiles, as
|
|
|
|
well as spam and moderation tools. Of course, other comment systems can be
|
2020-07-22 12:57:41 +03:00
|
|
|
integrated, too.
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
[Disqus]: https://disqus.com/
|
2020-07-22 12:57:41 +03:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2020-07-22 14:37:14 +03:00
|
|
|
### Disqus
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
[:octicons-tag-24: 1.1.0][Disqus support] ·
|
2020-07-23 16:34:43 +03:00
|
|
|
:octicons-milestone-24: Default: _none_
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
First, ensure you've set [`site_url`][site_url] in `mkdocs.yml`. Then, to
|
|
|
|
integrate Material for MkDocs with [Disqus], create an account and a site
|
|
|
|
giving you a [shortname], and add it to `mkdocs.yml`:
|
2020-07-22 14:37:14 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
extra:
|
|
|
|
disqus: <shortname>
|
|
|
|
```
|
2020-07-22 12:57:41 +03:00
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
This will insert a comment system on every page, except the index page.
|
2020-07-22 12:57:41 +03:00
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
[Disqus support]: https://github.com/squidfunk/mkdocs-material/releases/tag/1.1.0
|
|
|
|
[site_url]: https://www.mkdocs.org/user-guide/configuration/#site_url
|
|
|
|
[shortname]: https://help.disqus.com/en/articles/1717111-what-s-a-shortname
|
2020-07-22 12:57:41 +03:00
|
|
|
|
|
|
|
## Customization
|
|
|
|
|
|
|
|
### Selective integration
|
2020-07-22 14:37:14 +03:00
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
When [Metadata] is enabled, Disqus can be enabled or disabled for a document
|
|
|
|
with custom front matter. Add the following lines at the top of a Markdown file:
|
2020-07-23 16:34:43 +03:00
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
=== ":octicons-check-circle-fill-16: Enabled"
|
2020-07-22 14:37:14 +03:00
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
``` bash
|
2020-07-22 14:37:14 +03:00
|
|
|
---
|
|
|
|
disqus: <shortname>
|
|
|
|
---
|
2020-11-16 00:25:11 +03:00
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
# Document title
|
2020-11-16 00:25:11 +03:00
|
|
|
...
|
2020-07-22 14:37:14 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
=== ":octicons-skip-16: Disabled"
|
2020-07-22 14:37:14 +03:00
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
``` bash
|
2020-07-22 14:37:14 +03:00
|
|
|
---
|
|
|
|
disqus: ""
|
|
|
|
---
|
2020-11-16 00:25:11 +03:00
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
# Document title
|
2020-11-16 00:25:11 +03:00
|
|
|
...
|
2020-07-22 14:37:14 +03:00
|
|
|
```
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
[Metadata]: extensions/python-markdown.md#metadata
|
2020-07-31 10:35:24 +03:00
|
|
|
|
|
|
|
### Other comment systems
|
|
|
|
|
|
|
|
In order to integrate another JavaScript-based comment system provider, you can
|
2021-10-10 22:04:22 +03:00
|
|
|
[extend the theme], create a new `main.html` in `overrides` and [override the
|
|
|
|
`disqus` block][overriding blocks]:
|
2020-07-31 10:35:24 +03:00
|
|
|
|
|
|
|
``` html
|
2021-09-12 11:15:21 +03:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
2020-07-31 10:35:24 +03:00
|
|
|
{% block disqus %}
|
|
|
|
<!-- Add custom comment system integration here -->
|
|
|
|
{% endblock %}
|
|
|
|
```
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
[extend the theme]: ../customization.md#extending-the-theme
|
|
|
|
[overriding blocks]: ../customization.md#overriding-blocks
|