HUGO
Menu
GitHub 90156 stars Mastodon

path.Dir

Returns all but the last element of the given path, after replacing path separators with slashes (/).
Syntax
path.Dir PATH
Returns
string
{{ 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 "" }} → .