zola
zola copied to clipboard
Relative Urls support
I have been using zola for creating a simple static blog and it is working out great. However, I don't see any way to have relative links for pages, only the permalink variable is available.
Hugo has a relativeURLs configuration option which basically converts absolute links to relative links. For example, if your /posts/first/
page contains a link to /about/
, Hugo will rewrite the URL to ../../about/
.
Usage
I am currently hosting my blog on ipfs using Fleek. If I am using a browser like Brave, then the HTTP address will resolve and directly browse the site from ipfs. For example:
https://example.com -> ipns://[HASH]
But the base_url is https://example.com
, so anytime a permalink comes up, first the HTTP site opens which then resolves to ipfs. This just adds unnecessary steps, especially for things like the links to full post from post preview. It is significantly slower compared to a relative link.
So, is it already possible to do so or are there any plan to support relative URLs in Zola? I think there might be some other use cases where relative links are more useful than absolute links.
That's a hack, but I think using:
base_url = /
should work for your purpose.
Another solution is the use of
base_url = //example.com
as it will keep the existing protocol (so ipns: for your example)
@mscherer Thanks. I think I can work with it for now.
I would appreciate a get_relative_url()
filter as well.
That is needed not only for serve mode, but to avoid "leakage" in final content as well.
Non-leaking content is beneficial e.g. for privacy concerns. In Debian code project packaging it is raised as a privacy concern when distributed documentation content would go online when opening a web page, thereby revealing when and from where a Debian user is reading that piece of content.
I see absolutely no reason for e.g. link to a stylesheet to be an absolute URL.
See also related discussion at #686