Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'

```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
This commit is contained in:
Bjørn Erik Pedersen
2024-01-27 10:48:33 +01:00
1158 changed files with 64103 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
---
title: path.Base
description: Replaces path separators with slashes (`/`) and returns the last element of the given path.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/BaseName
- functions/path/Clean
- functions/path/Dir
- functions/path/Ext
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.Base PATH]
aliases: [/functions/path.base]
---
```go-html-template
{{ path.Base "a/news.html" }} → news.html
{{ path.Base "news.html" }} → news.html
{{ path.Base "a/b/c" }} → c
{{ path.Base "/x/y/z/" }} → z
{{ path.Base "" }} → .
```

View File

@@ -0,0 +1,28 @@
---
title: path.BaseName
description: Replaces path separators with slashes (`/`) and returns the last element of the given path, removing the extension if present.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/Clean
- functions/path/Dir
- functions/path/Ext
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.BaseName PATH]
aliases: [/functions/path.basename]
---
{{< new-in 0.101.0 >}}
```go-html-template
{{ path.BaseName "a/news.html" }} → news
{{ path.BaseName "news.html" }} → news
{{ path.BaseName "a/b/c" }} → c
{{ path.BaseName "/x/y/z/" }} → z
{{ path.BaseName "" }} → .
```

View File

@@ -0,0 +1,33 @@
---
title: path.Clean
description: Replaces path separators with slashes (`/`) and returns the shortest path name equivalent to the given path.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/BaseName
- functions/path/Dir
- functions/path/Ext
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.Clean PATH]
aliases: [/functions/path.clean]
---
See Go's [`path.Clean`] documentation for details.
[`path.Clean`]: https://pkg.go.dev/path#Clean
```go-html-template
{{ path.Clean "foo/bar" }} → foo/bar
{{ path.Clean "/foo/bar" }} → /foo/bar
{{ path.Clean "/foo/bar/" }} → /foo/bar
{{ path.Clean "/foo//bar/" }} → /foo/bar
{{ path.Clean "/foo/./bar/" }} → /foo/bar
{{ path.Clean "/foo/../bar/" }} → /bar
{{ path.Clean "/../foo/../bar/" }} → /bar
{{ path.Clean "" }} → .
```

View File

@@ -0,0 +1,27 @@
---
title: path.Dir
description: Replaces path separators with slashes (/) and returns all but the last element of the given path.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/BaseName
- functions/path/Clean
- functions/path/Ext
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.Dir PATH]
aliases: [/functions/path.dir]
---
```go-html-template
{{ path.Dir "a/news.html" }} → a
{{ path.Dir "news.html" }} → .
{{ path.Dir "a/b/c" }} → a/b
{{ path.Dir "/a/b/c" }} → /a/b
{{ path.Dir "/a/b/c/" }} → /a/b/c
{{ path.Dir "" }} → .
```

View File

@@ -0,0 +1,24 @@
---
title: path.Ext
description: Replaces path separators with slashes (`/`) and returns the file name extension of the given path.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/BaseName
- functions/path/Clean
- functions/path/Dir
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.Ext PATH]
aliases: [/functions/path.ext]
---
The extension is the suffix beginning at the final dot in the final slash-separated element of path; it is empty if there is no dot.
```go-html-template
{{ path.Ext "a/b/c/news.html" }} → .html
```

View File

@@ -0,0 +1,36 @@
---
title: path.Join
description: Replaces path separators with slashes (`/`), joins the given path elements into a single path, and returns the shortest path name equivalent to the result.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/BaseName
- functions/path/Clean
- functions/path/Dir
- functions/path/Ext
- functions/path/Split
- functions/urls/JoinPath
returnType: string
signatures: [path.Join ELEMENT...]
aliases: [/functions/path.join]
---
See Go's [`path.Join`] and [`path.Clean`] documentation for details.
[`path.Clean`]: https://pkg.go.dev/path#Clean
[`path.Join`]: https://pkg.go.dev/path#Join
```go-html-template
{{ path.Join "partial" "news.html" }} → partial/news.html
{{ path.Join "partial/" "news.html" }} → partial/news.html
{{ path.Join "foo/bar" "baz" }} → foo/bar/baz
{{ path.Join "foo" "bar" "baz" }} → foo/bar/baz
{{ path.Join "foo" "" "baz" }} → foo/baz
{{ path.Join "foo" "." "baz" }} → foo/baz
{{ path.Join "foo" ".." "baz" }} → baz
{{ path.Join "/.." "foo" ".." "baz" }} → baz
```

View File

@@ -0,0 +1,34 @@
---
title: path.Split
description: Replaces path separators with slashes (`/`) and splits the resulting path immediately following the final slash, separating it into a directory and file name component.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/BaseName
- functions/path/Clean
- functions/path/Dir
- functions/path/Ext
- functions/path/Join
returnType: paths.DirFile
signatures: [path.Split PATH]
aliases: [/functions/path.split]
---
If there is no slash in the given path, `path.Split` returns an empty directory, and file set to path. The returned values have the property that path = dir+file.
```go-html-template
{{ $dirFile := path.Split "a/news.html" }}
{{ $dirFile.Dir }} → a/
{{ $dirFile.File }} → news.html
{{ $dirFile := path.Split "news.html" }}
{{ $dirFile.Dir }} → "" (empty string)
{{ $dirFile.File }} → news.html
{{ $dirFile := path.Split "a/b/c" }}
{{ $dirFile.Dir }} → a/b/
{{ $dirFile.File }} → c
```

View File

@@ -0,0 +1,12 @@
---
title: Path functions
linkTitle: path
description: Template functions to work with file paths.
categories: []
keywords: []
menu:
docs:
parent: functions
---
Use these functions to work with file paths.