From 19d0aca2dda5e5a89f8f69b68ec282b53613eb26 Mon Sep 17 00:00:00 2001 From: Salar Nosrati-Ershad Date: Sun, 26 Nov 2023 22:37:20 +0330 Subject: [PATCH] fix: use relative urls when github publish enabled docs: add doc about enabling relative urls when github --- docs/settings.rst | 1 + pelican/tools/templates/Makefile.jinja2 | 5 +++++ pelican/tools/templates/publishconf.py.jinja2 | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/docs/settings.rst b/docs/settings.rst index e9edffde..1b449c5e 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -445,6 +445,7 @@ This would save your articles into something like Defines whether Pelican should use document-relative URLs or not. Only set this to ``True`` when developing/testing and only if you fully understand the effect it can have on links/feeds. + This option is enabled by default if you use github pages. .. data:: ARTICLE_URL = '{slug}.html' diff --git a/pelican/tools/templates/Makefile.jinja2 b/pelican/tools/templates/Makefile.jinja2 index 93ab1aa7..bc5cb672 100644 --- a/pelican/tools/templates/Makefile.jinja2 +++ b/pelican/tools/templates/Makefile.jinja2 @@ -45,7 +45,12 @@ ifeq ($(DEBUG), 1) PELICANOPTS += -D endif +{% if github %} +RELATIVE ?= 1 +{% else %} RELATIVE ?= 0 +{% endif %} + ifeq ($(RELATIVE), 1) PELICANOPTS += --relative-urls endif diff --git a/pelican/tools/templates/publishconf.py.jinja2 b/pelican/tools/templates/publishconf.py.jinja2 index 301e4dfa..f46913ed 100755 --- a/pelican/tools/templates/publishconf.py.jinja2 +++ b/pelican/tools/templates/publishconf.py.jinja2 @@ -9,7 +9,12 @@ from pelicanconf import * # If your site is available via HTTPS, make sure SITEURL begins with https:// SITEURL = "{{siteurl}}" + +{{ if github }} RELATIVE_URLS = False +{{ else }} +RELATIVE_URLS = True +{{ endif }} FEED_ALL_ATOM = "feeds/all.atom.xml" CATEGORY_FEED_ATOM = "feeds/{slug}.atom.xml"