Concatenate Url


I’m sure there is the answer somewhere but I keep struggling. I want to generate this Url in my template (an edit link):

After many tries, I’ve came up with that:

{{ path.Join .Site.Params.editUrl .File.Path }}

It works but it removes a slash in .Site.Params.editUrl. become https:/

So my url is missing a slash to work properly:


I probably don’t use the right function, but I always ended up with not the good url whatever I tried.

Thanks for your help !

Replace path.Join with add to make it handle schemas like “https://”.

You need to take care of slash at start and end of the strings when using add. It will not like path.Join handle that for you.

This would improve things a bit:

1 Like

Thank you very much both for your answers.

This is my code now and it works:

{{/* .File.Path has a backslash from windows, this transform it into a normal slash */}}
{{ $cleanUrl := path.Join .File.Path }}
{{ $editUrl := add .Site.Params.editUrl $cleanUrl }}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.