summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/urls.JoinPath.md
blob: c0e0464b6363316421170607eb691fea0d39b672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
title: urls.JoinPath
description: Joins the provided elements into a URL string and cleans the result of any ./ or ../ elements.
categories: [functions]
menu:
  docs:
    parent: functions
keywords: [urls,path,join]
signature: ["urls.JoinPath ELEMENT..."]
---

```go-html-template
{{ urls.JoinPath "" }} → "/"
{{ urls.JoinPath "a" }} → "a"
{{ urls.JoinPath "a" "b" }} → "a/b"
{{ urls.JoinPath "/a" "b" }} → "/a/b"
{{ urls.JoinPath "https://example.org" "b" }} → "https://example.org/b"

{{ urls.JoinPath (slice "a" "b") }} → "a/b"
```

Unlike the [`path.Join`] function, `urls.JoinPath` retains consecutive leading slashes.

[`path.Join`]: /functions/path.join/