HUGO
News Docs Themes Community GitHub

path.Dir

Replaces path separators with slashes (/) and returns all but the last element of the given path.

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: January 1, 0001
Improve this page