2020-07-22 13:37:14 +02:00
|
|
|
---
|
|
|
|
template: overrides/main.html
|
|
|
|
---
|
|
|
|
|
2020-07-22 11:57:41 +02:00
|
|
|
# Adding a comment system
|
|
|
|
|
|
|
|
Material for MkDocs is natively integrated with [Disqus][1], 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
|
|
|
|
integrated, too.
|
|
|
|
|
|
|
|
[1]: https://disqus.com/
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2020-07-22 13:37:14 +02:00
|
|
|
### Disqus
|
|
|
|
|
2020-07-23 15:34:43 +02:00
|
|
|
[:octicons-file-code-24: Source][2] ·
|
|
|
|
:octicons-milestone-24: Default: _none_
|
|
|
|
|
|
|
|
First, ensure you've set [`site_url`][3] in `mkdocs.yml`. Then, to integrate
|
2020-07-22 13:37:14 +02:00
|
|
|
Material for MkDocs with [Disqus][1], create an account and a site giving you a
|
2020-07-23 15:34:43 +02:00
|
|
|
[shortname][4], and add it to `mkdocs.yml`:
|
2020-07-22 13:37:14 +02:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
extra:
|
|
|
|
disqus: <shortname>
|
|
|
|
```
|
2020-07-22 11:57:41 +02:00
|
|
|
|
2020-07-22 13:37:14 +02:00
|
|
|
This will insert a comment system on _every page, except the index page_.
|
2020-07-22 11:57:41 +02:00
|
|
|
|
2020-07-23 15:34:43 +02:00
|
|
|
[2]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/integrations/disqus.html
|
|
|
|
[3]: https://www.mkdocs.org/user-guide/configuration/#site_url
|
|
|
|
[4]: https://help.disqus.com/en/articles/1717111-what-s-a-shortname
|
2020-07-22 11:57:41 +02:00
|
|
|
|
|
|
|
## Customization
|
|
|
|
|
|
|
|
### Selective integration
|
2020-07-22 13:37:14 +02:00
|
|
|
|
2020-07-23 15:34:43 +02:00
|
|
|
[:octicons-file-code-24: Source][2] ·
|
2020-12-21 17:38:58 +01:00
|
|
|
:octicons-note-24: Metadata ·
|
2020-07-23 15:34:43 +02:00
|
|
|
:octicons-mortar-board-24: Difficulty: _easy_
|
|
|
|
|
2021-05-01 17:53:39 +02:00
|
|
|
If the [Metadata][5] extension is enabled, you can disable or enable Disqus for
|
2020-07-22 13:37:14 +02:00
|
|
|
specific pages by adding the following to the front matter of a page:
|
|
|
|
|
|
|
|
=== "Enable Disqus"
|
|
|
|
|
2020-11-15 22:25:11 +01:00
|
|
|
``` yaml
|
2020-07-22 13:37:14 +02:00
|
|
|
---
|
|
|
|
disqus: <shortname>
|
|
|
|
---
|
2020-11-15 22:25:11 +01:00
|
|
|
|
|
|
|
...
|
2020-07-22 13:37:14 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
=== "Disable Disqus"
|
|
|
|
|
2020-11-15 22:25:11 +01:00
|
|
|
``` yaml
|
2020-07-22 13:37:14 +02:00
|
|
|
---
|
|
|
|
disqus: ""
|
|
|
|
---
|
2020-11-15 22:25:11 +01:00
|
|
|
|
|
|
|
...
|
2020-07-22 13:37:14 +02:00
|
|
|
```
|
|
|
|
|
2021-05-01 17:53:39 +02:00
|
|
|
[5]: ../../reference/meta-tags/#metadata
|
2020-07-31 09:35:24 +02:00
|
|
|
|
|
|
|
### Other comment systems
|
|
|
|
|
2021-05-01 17:53:39 +02:00
|
|
|
[:octicons-file-code-24: Source][6] ·
|
2020-07-31 09:35:24 +02:00
|
|
|
:octicons-mortar-board-24: Difficulty: _easy_
|
|
|
|
|
|
|
|
In order to integrate another JavaScript-based comment system provider, you can
|
2021-05-01 17:53:39 +02:00
|
|
|
[extend the theme][7] and [override the `disqus` block][8]:
|
2020-07-31 09:35:24 +02:00
|
|
|
|
|
|
|
``` html
|
|
|
|
{% block disqus %}
|
|
|
|
<!-- Add custom comment system integration here -->
|
|
|
|
{% endblock %}
|
|
|
|
```
|
|
|
|
|
2021-05-01 17:53:39 +02:00
|
|
|
[6]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html
|
|
|
|
[7]: ../customization.md#extending-the-theme
|
2021-05-01 20:26:54 +02:00
|
|
|
[8]: ../customization.md#overriding-blocks-recommended
|