I created a quickstart website following the instructions here, then created the following shortcode:
- layouts/shortcodes/baseurl.html
{{ $base := .Site.BaseURL }}{{ $parsed := urls.Parse $base }}{{ $path := $parsed.Path }}{{ if not (eq $path "/") }}{{- $path -}}{{ end }}
then modified content/posts/my-first-post.md and added the following:
[example1]({{< baseurl >}}foo)
[example2]({{< baseurl >}}/foo)
the hugo.toml file is as per the example:
baseURL = 'https://example.org'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = 'ananke'
considering that a slash is always appended to .Site.BaseURL, $path in both shortcodes usages should be /.
Now looking at the hyperlinks in the page I see:
why are the two links different?