path.Base
Returns the last element of the given path.
- Syntax
- path.Base PATH
- Returns
- string
Usage
The path.Base function returns the last element of the given path. The function removes trailing slashes before it extracts the last element.
On Windows, the function first replaces each backslash (\) in its arguments with a slash (/).
Examples
{{ path.Base "a/news.html" }} → news.html
{{ path.Base "news.html" }} → news.html
{{ path.Base "a/b/c" }} → c
{{ path.Base "/x/y/z/" }} → zEmpty paths and paths that contain only slashes:
{{ path.Base "" }} → .
{{ path.Base "/" }} → /Last updated:
November 12, 2026
:
content: Apply style guide to path functions (0fd00f291)
Improve this page