#3513·pelican

`RELATIVE_URLS = True` replaces `SITEURL` in global context

Author: galaxy4publicCreated Oct 15, 2025Updated Sep 13, 2026
Labelsbug
  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I can reproduce this problem with stock/default settings file, theme, and sample content (as described in above “How to Get Help” sections of the documentation).
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • Python version: 3.9.6
  • Pelican version: 4.11.0

Issue

There is a setting, called RELATIVE_URLS which is by default set to False. This generates absolute URLs for every link. The option comes with i big sign that there are dragons if you enable it. Indeed there are :). I checked the source code and it seems to me that there is just one bug that leads to conceptually unexpected behavior. Namely, if you set RELATIVE_URLS = True then Pelican will overwrite SITEURL with a relative path. However, this overwritten variable is never actually used for links and instead localsiteurl is used for that purpose.

I believe the following line in writers.py is erroneous and should be simply removed from the source code:

            if relative_urls:
                relative_url = path_to_url(get_relative_path(name))
                localcontext["SITEURL"] = relative_url. #  <<<<<<<<<< this line should be removed
                localcontext["localsiteurl"] = relative_url

The effect of removing the suggested line is that the relative URL logic still functions as expected since _update_content() calls self.get_siteurl() which returns localsiteurl from the current context. The benefit of the removal would be that one could use {{ SITEURL }} in templates to refer to the absolute path when it is necessary while still getting the relative links for generated stuff. :). Right now, we are forced to find workarounds (e.g. I am using FEED_DOMAIN to achieve the same, since FEED_DOMAIN is assigned from SITEURL before the latter is re-writen by the RELATIVE_URLS logic.

I think it is just wrong that a setting that affects the generation behaviour overwrites the config variable and makes it unavailable to templates. In any case, this is just a suggestion :).