mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
25 lines
770 B
Markdown
25 lines
770 B
Markdown
---
|
|
title: urls.JoinPath
|
|
description: Joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. If the argument list is empty, JoinPath returns an empty string.
|
|
categories: [functions]
|
|
menu:
|
|
docs:
|
|
parent: functions
|
|
keywords: [urls,path,join]
|
|
signature: ["urls.JoinPath ELEMENT..."]
|
|
---
|
|
|
|
```go-html-template
|
|
{{ urls.JoinPath }} → ""
|
|
{{ 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/
|