Instantly share code, notes, and snippets.

Embed
What would you like to do?
Canonical URLs with Jekyll
<link rel="canonical" href="http://yourdomain.com{{ page.url | replace:'index.html','' }}" />
@StarWar

This comment has been minimized.

Copy link

StarWar commented Jan 19, 2013

I've set a production_url in config
I use this:

<link rel="canonical" href="{{ site.production_url }}{{ page.url | replace:'index.html',''}}">

@smileprem

This comment has been minimized.

Copy link

smileprem commented Jan 27, 2014

Thanks guys. I have used this the code by StarWar.

@quangbahoa

This comment has been minimized.

Copy link

quangbahoa commented May 14, 2014

Here is default config for site.url

<link rel="canonical" href="{{ site.url }}{{ page.url | replace:'index.html',''}}">
@filippovitale

This comment has been minimized.

Copy link

filippovitale commented Oct 2, 2018

In case you set the baseurl on _config.yml

<link rel="canonical" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html',''}}">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment