https://github.com/fabiomux/jekyll-disqus-plugin
Jekyll plugin that provides all the required tags to render the Disqus comment section and the counter.
https://github.com/fabiomux/jekyll-disqus-plugin
disqus jekyll jekyll-plugin ruby ruby-gem
Last synced: about 2 months ago
JSON representation
Jekyll plugin that provides all the required tags to render the Disqus comment section and the counter.
- Host: GitHub
- URL: https://github.com/fabiomux/jekyll-disqus-plugin
- Owner: fabiomux
- License: gpl-3.0
- Created: 2023-02-21T09:33:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-27T17:57:09.000Z (over 2 years ago)
- Last Synced: 2026-03-15T13:12:07.510Z (4 months ago)
- Topics: disqus, jekyll, jekyll-plugin, ruby, ruby-gem
- Language: Ruby
- Homepage: https://freeaptitude.altervista.org/projects/jekyll-disqus.html
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Jekyll-Disqus
This is a Jekyll plugin that provides the Liquid tags to render the Disqus Javascript codes inside the
theme template.
It also associates a different *ID* to every *post* using its publishing date and ensures the uniqueness
of that ID among all the posts.
Although the *ID* can be automatically generated is still possible to declare a custom *ID*, which is
mandatory for those pages that don't contain a publishing date but recall one of the Disqus tags in
their layouts.
[][wf_main]
[][gem_version]
## Installation
Can install the gem either manually or using *Bundler*.
### Using Bundler
Install the gem and add to the application's Gemfile by executing:
$ bundle add jekyll-disqus-plugin --group jekyll_plugins
### Manually
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install jekyll-disqus-plugin
Then, add the following code within the Gemfile of your Jekyll project:
```ruby
group :jekyll_plugins do
...
gem 'jekyll-disqus-plugin'
end
```
## Configuration
Inside the `_config.yml` file can set up the following fields:
```yaml
jekyll-disqus:
shortname:
id_prefix:
post_selector: 'include.post'
ui:
layouts:
- 'post'
counter:
layouts:
- 'all'
```
*shortname*
: It is the same *Shortname* provided by Disqus for each site added.
*id_prefix*
: It is a code that will be prepended to any *Disqus Id*, just to add another level of customization.
*post_selector*
: This is how the script will read the post data inside a paginator layout.
*ui.layouts*/*counter.layouts*
: A list of layouts where the two couple of tags will be printed.
To disable the tags for specific pages or posts, the *no_disqus* field can be set up to true on the front
matter of the specific post or page itself.
By default, this addon associates a unique *ID* to each *post* using the related publishing date, but
where needed, a *disqus_id* field can be declared in the front matter of the page.
```yaml
---
title: ...
description: ...
author: ...
...
disqus_id: 'CUSTOM_DISQUS_ID'
...
```
There is a deep relationship between the *disqus_id* and the related post, so be sure that:
- The custom disqus_id will remain unique, otherwise an error will be raised at the building time;
- the custom disqus_id won't change after the page has been published, otherwise all the comments
associated with the post will be lost;
- the publishing date, where the *ID* is not customized, doesn't change, or all the comments associated
with the post will be lost.
## Usage
Below are the provided tags:
| Tag | Description | Template |
|:---------------------------:|-----------------------------------------------------|:--------:|
| {% disqus_counter %} |The count of comments for a certain post | Post |
| {% disqus_script_counter %} |The required Javascript that renders the counter | Default |
| {% disqus_ui %} |The comment box | Post |
| {% disqus_script_ui %} |The required Javascript that renders the comment box | Default |
The *script* tags must be included once for page and, providing a Javascript code, their position should
be in the bottom part of the main layout, just before the end of the *body* HTML tag.
The *disqus_ui* renders the comment box and should be put in the post or page layout, depending
where you want to show it, usually after the *content* has been printed.
The *disqus_counter* shows the number of comments for a post (or page), and it is
bound to the specific content through the *disqus_id* aforementioned.
Usually, it is displayed among the content *data*, just after the title, and it works for the full
rendered post as well as the paginated content.
In the last case, the plugin will detect the post included in the pagination template using a selector.
By default, it is `include.post`, but can be changed in the configuration section of the `_config.yml`
file.
## More Help
More info is available at:
- the [project page on the Freeaptitude blog][project_page];
- the [Jekyll-Disqus Github wiki][jekyll_disqus_wiki].
[project_page]: https://freeaptitude.altervista.org/projects/jekyll-disqus.html "Project page on the Freeaptitude blog"
[jekyll_disqus_wiki]: https://github.com/fabiomux/jekyll-disqus-plugin/wiki "Jekyll-Disqus wiki page on GitHub"
[wf_main]: https://github.com/fabiomux/jekyll-disqus-plugin/actions/workflows/main.yml
[gem_version]: https://badge.fury.io/rb/jekyll-disqus-plugin