-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use canonicalUrl filter in Atom feed #272
Conversation
Switching to using the custom `canonicalUrl` filter defined in this plugin rather than the `absoluteUrl` filter defined in the `eleventy-plugin-rss` plugin, so the URLs will include any `pathPrefix` defined in the Eleventy config.
This was all pretty confusing. Perhaps long-term we should aim to remove the I think my ideal would be for |
Before merging, do you want to try using the |
Oh wait! I think I know why you can’t! {{ "/path/to/file" | url }}
{# returns "/pathPrefix/path/to/file" #} However, Atom feeds and other places require a fully resolved URL. That’s why I added {{ "/path/to/file" | canonicalUrl }}
{# returns "https://website.example/pathPrefix/path/to/file" #} Might want to double-check that is true, but from memory that’s what’s going on here. |
@paulrobertlloyd yes, it's all very confusing! As I understand it, So, I think there’s (at least) 3 different ways to do this (tested all these locally):
The other thing I’ve realised is that
I think for consistency we should stick with 🤯 |
Yeah, let’s merge for now and review the use of this filter when Eleventy 3.0.0 comes out; I suspect there might be a lot of things we’ll do a bit differently 🤞 |
Switching to using the custom
canonicalUrl
filter defined in this plugin rather than theabsoluteUrl
filter defined in theeleventy-plugin-rss
plugin, so the URLs will include anypathPrefix
defined in the Eleventy config.This is because, I think, the two filters work in subtly different ways:
absoluteUrl
resolves a path with a base url, which means that:'/path/test' | absoluteUrl('https://example.test/prefix')
returnshttps://example.test/path/test
- as the initial/
in the path indicates a root-relative url.canonicalUrl
appends the paths together, which means that:'/path/test' | canonicalUrl('https://example.test/prefix/')
returnshttps://example.test/prefix/path/test
An alternative solution would be to use the
url
filter from Eleventy or the HTML base plugin included with Eleventy 2.0+ - however that one still wouldn't work on the Atom feed as it only transforms links in HTML automatically, and so we’d have to use thehtmlBaseUrl
filter instead. 🤯