mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-01 16:19:14 -05:00
24 lines
683 B
Markdown
24 lines
683 B
Markdown
---
|
|
title: path.Clean
|
|
description: Replaces path separators with slashes (`/`) and removes extraneous separators.
|
|
categories: [functions]
|
|
menu:
|
|
docs:
|
|
parent: functions
|
|
keywords: [path, clean]
|
|
signature: ["path.Clean PATH"]
|
|
relatedfuncs: [path.Base, path.BaseName, path.Dir, path.Ext, path.Join, path.Split]
|
|
---
|
|
|
|
`path.Clean` replaces path separators with slashes (`/`) and removes extraneous separators, including trailing separators.
|
|
|
|
```go-html-template
|
|
{{ path.Clean "foo//bar" }} → "foo/bar"
|
|
{{ path.Clean "/foo/bar/" }} → "/foo/bar"
|
|
```
|
|
|
|
On a Windows system, if `.File.Path` is `foo\bar.md`, then:
|
|
|
|
```go-html-template
|
|
{{ path.Clean .File.Path }} → "foo/bar.md"
|
|
```
|