0.03
No release in over 3 years
Low commit activity in last 3 years
A Middleman extension to integrate Disqus into your site, supporting Disqus configuration variables and comment counts.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Middleman Disqus

Build Status Gem Version Dependency Status Code Climate

Middleman-Disqus is a Middleman extension that generates the Disqus embed code, and keeps your config in config.rb, where it belongs.

Installation

  1. Specify the dependency in your project's Gemfile:
# Gemfile
gem "middleman-disqus"
  1. Activate the Disqus extension in your project's config.rb. (n.b. read important information about shortnames)
# config.rb
activate :disqus do |d|
  d.shortname = 'your-shortname' # Replace with your Disqus shortname.
end
  1. In your layout or template call disqus and/or discus_count and include the results in the page:

Haml:

/ link with `#disqus_thread` is optional if not using `disqus_count` -->
%a{:href => "http://example.com/foo.html#disqus_thread"} Comments

= disqus
= disqus_count

ERB:

<!-- link with `#disqus_thread` is optional if not using `disqus_count` -->
<a href="http://example.com/foo.html#disqus_thread">Comments</a>

<%= disqus %>
<%= disqus_count %>

Helper methods

The following helper methods are available within your templates:

  • disqus will include the Disqus embed.js code and display comments.
  • disqus_count will include the Disqus count.js code for displaying a comment count on links when you set #disqus_thread to the href attribute.

Configuration: config.rb

activate :disqus do |d|
  # Disqus shotname, without '.disqus.com' on the end (default = nil)
  d.shortname = 'your_shortname'
end

Configuration: YAML Frontmatter

You can set per page configuration variables in the YAML Fontmatter, these are used as parameters for Disqus' behaviors and settings.

For full details about what they do, see Disqus JavaScript configuration variables

---
disqus_identifier: /2012/the-best-day-of-my-life.html
disqus_title: The best day of my life
disqus_url: http://example.com/2012/the-best-day-of-my-life.html
disqus_category_id: 4
disqus_disable_mobile: true
---

Page with YAML Frontmatter.

IMPORTANT: Do not use real shortnames during development

If you use the live/production shortname during development and testing, expect to litter your Disqus account with discussions that you can't delete!

You have two options:

  • Create a special testing/development shortname for use during development.
  • Only include Disqus in builds, not when running middleman server.

You can set different options for build and development by using Middleman's environment specific settings, for example:

# config.rb
configure :development do
  activate :disqus do |d|
    # using a special shortname
    d.shortname = "development-shortname"
    # or setting to `nil` will stop Disqus loading
    d.shortname = nil
  end
end

configure :build do
  activate :disqus do |d|
    # using a different shortname for production builds
    d.shortname = "production-shortname"
  end
end

License

Usage is provided under the MIT License. See the LICENSE file for the full details.