Browse code

Use canonical URL for Disqus, fixes #236

Frederic Hemberger authored on 21/10/2011 at 12:04:34
Showing 2 changed files
... ...
@@ -1,13 +1,12 @@
1 1
 {% comment %} Load script if disquss comments are enabled and `page.comments` is either empty (index) or set to true {% endcomment %}
2 2
 {% if site.disqus_short_name and page.comments != false %}
3 3
 <script type="text/javascript">
4
-    
5 4
       var disqus_shortname = '{{ site.disqus_short_name }}';
6 5
       {% if page.comments == true %}
7 6
         {% comment %} `page.comments` can be only be set to true on pages/posts, so we embed the comments here. {% endcomment %}
8 7
         // var disqus_developer = 1;
9
-        var disqus_identifier = '{{ site.url }}{{ page.url }}';
10
-        var disqus_url = '{{ site.url }}{{ page.url }}';
8
+        var disqus_identifier = '{{ canonical }}';
9
+        var disqus_url = '{{ canonical }}';
11 10
         var disqus_script = 'embed.js';
12 11
       {% else %}
13 12
         {% comment %} As `page.comments` is empty, we must be on the index page. {% endcomment %}
... ...
@@ -16,7 +16,7 @@
16 16
   <meta name="MobileOptimized" content="320">
17 17
   <meta name="viewport" content="width=device-width, initial-scale=1">
18 18
 
19
-  {% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
19
+  {% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %}
20 20
   <link rel="canonical" href="{{ canonical }}">
21 21
   <link href="{{ root_url }}/favicon.png" rel="icon">
22 22
   <link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">