path.Clean

将以下英文翻译为中文:

path.Clean

https://gohugo.io/functions/path.clean/

Replaces path separators with slashes (/) and removes extraneous separators.

语法

path.Clean PATH

path.Clean replaces path separators with slashes (/) and removes extraneous separators, including trailing separators.

1
2
{{ path.Clean "foo//bar" }} → "foo/bar"
{{ path.Clean "/foo/bar/" }} → "/foo/bar"

On a Windows system, if .File.Path is foo\bar.md, then:

1
{{ path.Clean .File.Path }} → "foo/bar.md"

另请参阅