emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
280 stars 21 forks source link

Make relative URLs in {{ post.html }} rendered as absolute URLs #30

Open semente opened 3 years ago

semente commented 3 years ago

As I mentioned in issue #27, I would to use Org's [[file:path/to/file.org]] links to be able to browse Org files in Emacs the same way I would in a web browser.

But I just found an issue with this way of linking internal pages: If a have a link like [[file:example.txt]] in a post posts/post.org its rendered href HTML property (i.e. example.txt) will work just fine in a web browser, which will use the http://example.net/posts/ as the base URL. But the same won't work in RSS files causing it to be rendered as http://example.net/example.txt.

This issue won't happen if I link stuff using the form [[url_for:ROUTE,slug=SLUG]] because it generates an absolute URL but this might be an issue if you try to export this same file, let's say to Markdown, using org-publish. Also, if you use #+OPTIONS: toc, the anchored links it generates will also be relative and won't work in a RSS reader.

So my proposal here is to make post.html to always render internal links as absolute URLs.

clarete commented 3 years ago

great find! thank you once again for the thoroughly written report 🙇🏾 I'll look for a setting that could be passed to ox-html to render links with absolute URLs!