Skip to content

Commit f3c68bb

Browse files
committed
Do not strip trailing slash of canonical URLs.
Usually, links for posts are generated with a trailing slash, but canonical URLs aren't. Some services (e.g. http://b.hatena.ne.jp/) are confused with that behavior. We can fix it by removing canonical URLs, but then anyone may read a post with /index.html URL and post the URL to some tool or service. Therefore rel="canonical" seems useful IMHO. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
1 parent e53b26a commit f3c68bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.themes/classic/source/_includes/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<meta name="MobileOptimized" content="320">
1717
<meta name="viewport" content="width=device-width, initial-scale=1">
1818

19-
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %}
19+
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
2020
<link rel="canonical" href="{{ canonical }}">
2121
<link href="{{ root_url }}/favicon.png" rel="icon">
2222
<link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">

0 commit comments

Comments
 (0)