mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -1,26 +0,0 @@
|
||||
---
|
||||
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 "" }} → .
|
||||
```
|
@@ -1,28 +0,0 @@
|
||||
---
|
||||
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 "" }} → .
|
||||
```
|
@@ -1,33 +0,0 @@
|
||||
---
|
||||
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 "" }} → .
|
||||
```
|
@@ -1,27 +0,0 @@
|
||||
---
|
||||
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 "" }} → .
|
||||
```
|
@@ -1,24 +0,0 @@
|
||||
---
|
||||
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
|
||||
```
|
@@ -1,36 +0,0 @@
|
||||
---
|
||||
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
|
||||
```
|
@@ -1,34 +0,0 @@
|
||||
---
|
||||
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
|
||||
```
|
@@ -1,12 +0,0 @@
|
||||
---
|
||||
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.
|
Reference in New Issue
Block a user