What's the point of using absolute urls in Pelican?
Asked Answered
W

1

10

About RELATIVE_URLS, the Pelican docs say:

…there are currently two supported methods for URL formation: relative and absolute. Relative URLs are useful when testing locally, and absolute URLs are reliable and most useful when publishing.

(http://pelican.readthedocs.org/en/3.4.0/settings.html#url-settings)

But I'm confused why absolute URLs would be better or not. In general, when I write HTML by hand I prefer to use relative URLs because I can change the domain of the website and not worry about it later.

Can somebody explain the thinking behind this setting in more detail?

Wakayama answered 22/8, 2014 at 16:30 Comment(1)
I think you're referring to root-relative links, not relative links. The problem is Pelican provides relative links (mypage.html) and absolute links (http://example.com/mypage.html) but not root-relative links (/mypage.html). I don't know why Pelican doesn't support root-relative links.Indwell
T
3

I don't use the RELATIVE_URLS setting because it's document-relative. I don't want URLs containing ../.. in them, which is often what happens when that setting is used.

Moreover, relative URLs can cause issues in Atom/RSS feeds, since all links in feeds must be absolute as per the respective feed standard specifications.

Contrary to what's implied in the original question, not using the RELATIVE_URLS setting will not cause any 404s if you later decide to change the domain. There's a difference between specifying absolute URLs in your source document (which is what you seem to be talking about) and having absolute URLs generated for you at build time (which is what Pelican does).

When it comes time to link to your own content, you can either use root-relative links, or you can use the intra-site link syntax that Pelican provides.

Tough answered 22/8, 2014 at 18:24 Comment(3)
So this is all about output? Who cares if your HTML has ../.. in it? The whole idea of a SSG is you don't have to think about your HTML? :confused:Wakayama
The purpose of this setting is to specify how links are formulated when the output is generated. For what it's worth, I care if my HTML has ../.. in it, for reasons I've already explained above.Tough
You don't "have to think about your HTML," but it seems from your original question that's what you want to do. I've already proposed my suggestion: don't use the RELATIVE_URLS setting, and use the intra-site link syntax.Tough

© 2022 - 2024 — McMap. All rights reserved.