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 "" }} → .Last updated:
September 11, 2026
:
content: Comply with function/method description guidance in style guide (76fa3fc9e)
Improve this page