path.BaseName

将以下英文翻译为中文:

path.BaseName

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

BaseName returns the last element of a path, removing the extension if present.

语法

path.BaseName PATH

If PATH is empty, . is returned.

Note: On Windows, PATH is converted to slash (/) separators.

1
2
3
4
{{ path.BaseName "a/news.html" }} → "news"
{{ path.BaseName "news.html" }} → "news"
{{ path.BaseName "a/b/c" }} → "c"
{{ path.BaseName "/x/y/z/" }} → "z"

另请参阅