Skip to content

Conversation

@dolfs
Copy link

@dolfs dolfs commented Jan 23, 2026

Type of change

  • [x ] Improvement (refactoring and improving code)

Description

There was code in the post and home layouts that, in part, duplicated the work done in media-url.html. Instead they should use that include (DNRY principle) to also get the benefit of the fixes in #2389.

Additional context

depends-on: PR #2648

dolfs added 2 commits January 22, 2026 21:39
When baseurl in _config.yml is not empty, without this fix, it can be prepended more than once, which is incorrect.

This fix adds logic to prevent prepending the baseurl when it is already a prefix in the url, but correctly handles cases where it is a prefix, but the url does not follow this prefix with a path/url separator.

For example, when baseurl is set to /blog, but the url starts with /blogger it is not considered "prefixed" and /blog/ is prepended (resulting in /blog/blogger…, but if the url starts with /blog/it is considered "prefixed" and is not prepended again (keeping/resulting in/blog/…`)

A limitation is that if the user supplied a (partial) URL starting with /blog/ and truly intended to produce /blog/blog/, it won't work.

Fixes: cotes2020#2639
Signed-off-by: Dolf Starreveld <[email protected]>
…riately

Both home and post layouts did some of the work already done by _include/media-url.html. Since that _include was fixed to deal with the double prepend of baseurl, these layouts still had the problem.

Change that so they use the include. Only effective when the previous PR is also merged.

depends-on: PR cotes2020#2648
Signed-off-by: Dolf Starreveld <[email protected]>
@github-actions github-actions bot closed this Jan 23, 2026
@github-actions
Copy link

Oops, it seems you've opened an invalid pull request. No worries, we'll close it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant