mkdocs-material/docs/setup/adding-a-comment-system.md

83 lines
2.0 KiB
Markdown
Raw Normal View History

---
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
### Disqus
2021-10-10 22:04:22 +03:00
[:octicons-tag-24: 1.1.0][Disqus support] ·
: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`:
``` 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
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:
2021-10-10 22:04:22 +03:00
=== ":octicons-check-circle-fill-16: Enabled"
2021-05-30 16:59:13 +03:00
``` bash
---
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
...
```
2021-10-10 22:04:22 +03:00
=== ":octicons-skip-16: Disabled"
2021-05-30 16:59:13 +03:00
``` bash
---
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
...
```
2021-10-10 22:04:22 +03:00
[Metadata]: extensions/python-markdown.md#metadata
### 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]:
``` html
{% extends "base.html" %}
{% 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