Skip to content

fix: use `relative_url` for compat w/ local build

context

all links/hrefs in the site use the format {{ /absolute/path | prepend: site.url }}

while this works fine on the canonical website hosted on the GitLab Pages instance, it makes local development difficult.

solution

  1. set site.baseurl (and site.url)
  2. use {{ ... | relative_url }}

explaining solution

{{ | relative_url }}

from docs

Prepend baseurl config value to the input to convert a URL path into a relative URL.
This is recommended for a site that is hosted on a subpath of a domain.

site.baseurl

for relative_url to work, the key baseurl is added to _config.yml the value is set as the path to the site

site.url

this value is set to the proto://FQDN of the site. in local builds run with jekyll serve the values provided to --host and --port are used, allowing for seamless developer experience. source

Edited by Kevin Samuel

Merge request reports