| 1 |
--- |
| 2 |
title: path.BaseName |
| 3 |
description: Returns the last element of the given path with its extension removed, if present, after replacing path separators with slashes (`/`). |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: string |
| 10 |
signatures: [path.BaseName PATH] |
| 11 |
aliases: [/functions/path.basename] |
| 12 |
--- |
| 13 |
|
| 14 |
```go-html-template |
| 15 |
{{ path.BaseName "a/news.html" }} → news |
| 16 |
{{ path.BaseName "news.html" }} → news |
| 17 |
{{ path.BaseName "a/b/c" }} → c |
| 18 |
{{ path.BaseName "/x/y/z/" }} → z |
| 19 |
{{ path.BaseName "" }} → . |
| 20 |
``` |