| 1 |
--- |
| 2 |
title: path.Join |
| 3 |
description: Returns the shortest path name equivalent to the given path elements joined into a single path, after replacing path separators with slashes (`/`). |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: string |
| 10 |
signatures: [path.Join ELEMENT...] |
| 11 |
aliases: [/functions/path.join] |
| 12 |
--- |
| 13 |
|
| 14 |
See Go's [`path.Join`][] and [`path.Clean`][] documentation for details. |
| 15 |
|
| 16 |
```go-html-template |
| 17 |
{{ path.Join "partial" "news.html" }} → partial/news.html |
| 18 |
{{ path.Join "partial/" "news.html" }} → partial/news.html |
| 19 |
{{ path.Join "foo/bar" "baz" }} → foo/bar/baz |
| 20 |
{{ path.Join "foo" "bar" "baz" }} → foo/bar/baz |
| 21 |
{{ path.Join "foo" "" "baz" }} → foo/baz |
| 22 |
{{ path.Join "foo" "." "baz" }} → foo/baz |
| 23 |
{{ path.Join "foo" ".." "baz" }} → baz |
| 24 |
{{ path.Join "/.." "foo" ".." "baz" }} → baz |
| 25 |
``` |
| 26 |
|
| 27 |
[`path.Clean`]: https://pkg.go.dev/path#Clean |
| 28 |
[`path.Join`]: https://pkg.go.dev/path#Join |