path.Ext
Returns the file extension of the given path.
- Syntax
- path.Ext PATH
- Returns
- string
Usage
The path.Ext function returns the file extension of the given path. The extension is the suffix that begins at the final dot in the last slash-separated element of the path. If the last element does not contain a dot, the function returns an empty string.
On Windows, the function first replaces each backslash (\) in its arguments with a slash (/).
Examples
{{ path.Ext "a/b/c/news.html" }} → .html
{{ path.Ext "archive.tar.gz" }} → .gz
{{ path.Ext ".gitignore" }} → .gitignorePaths without a dot in the last element:
{{ path.Ext "a/b/c/news" }} → "" (empty string)
{{ path.Ext "a.b/c" }} → "" (empty string)Last updated:
November 12, 2026
:
content: Apply style guide to path functions (0fd00f291)
Improve this page