Skip to content

Fix hreflang and canonical url (hopefully the right way this time)

It seems jekyll-ployglot has a feature where it rewrites URLs to have the current language, but it does it by matching site.url, so it was behaving differently on my vagrant VM with site.url set to localhost. I was hardcoding the URL because that prevented rewrites in vagrant, but it seems that's not necessary, so I switched back to the absolute_url filter.

The docs (see the "Disabling Url Relativizing" section) say the way to stop it is to include a leading space, which looks like just causes a regex to not match. Using single quotes also seems to work, and not leave the output with a leading space in the link. I think having spaces is valid, but seems a little weird. The jekyll-polyglot docs suggest using a minifer too.

I obviously prefer the single quotes, but not strongly enough to argue with anyone about it, if the leading space seems preferable 😄

Merge request reports