Skip to content

'/' missing in canonical link in the category pages #949

Description

@floydpink

First up, thanks heaps for Octopress! Love it!

Here's my setup:
The blog (deployed here) is being published to the /blogs sub-directory of an existing gh-pages branch, whose root has the main site. (As an aside, the rake deploy script has been tweaked slightly to accommodate the main site as well, to the effect that there is a git pull --rebase from gh-pages first, and then a git push).

Running on Windows 7, with Git Bash and Ruby 1.9.3 installed via RubyInstaller.
The blog source is here.

The issue I have is that the canonical link url in the category pages alone, are all with the / between blogs and blog missing.

After source\_includes\head.html was tweaked as below (to see the variables that are in play to generate the canonical url):

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

...here are the excerpts from:

  • public\blogs\blog\archives\index.html ( good )
  <!-- site.url: http://flickrdownloadr.com/blogs -->
  <!-- site.permalink: /blog/:year/:month/:day/:title/ -->
  <!-- page.url: /blog/archives/index.html -->
  <!-- canonical: http://flickrdownloadr.com/blogs/blog/archives/ -->
  <link rel="canonical" href="http://flickrdownloadr.com/blogs/blog/archives/">
  • public\blogs\index.html ( good )
  <!-- site.url: http://flickrdownloadr.com/blogs -->
  <!-- site.permalink: /blog/:year/:month/:day/:title/ -->
  <!-- page.url: /index.html -->
  <!-- canonical: http://flickrdownloadr.com/blogs/ -->
  <link rel="canonical" href="http://flickrdownloadr.com/blogs/">
  • and public\blogs\blog\categories\general ( bad! )
  <!-- site.url: http://flickrdownloadr.com/blogs -->
  <!-- site.permalink: /blog/:year/:month/:day/:title/ -->
  <!-- page.url: blog/categories/general/index.html -->
  <!-- canonical: http://flickrdownloadr.com/blogsblog/categories/general/ -->
  <link rel="canonical" href="http://flickrdownloadr.com/blogsblog/categories/general/">

So, I see that the page.url not starting with a / is what is causing the canonical link in the category pages to be generated incorrectly, but I do not know if this is just me alone or how I could fix this.

Could someone help please?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions