summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/path.Clean.md
blob: 852de65fd5dd2c9de42b139b61ce0c3018337d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
title: path.Clean
description: Replaces path separators with slashes (`/`) and removes extraneous separators.
date: 2021-10-08
# publishdate: 2018-11-28
# lastmod: 2018-11-28
categories: [functions]
menu:
  docs:
    parent: "functions"
keywords: [path, clean]
signature: ["path.Clean PATH"]
relatedfuncs: [path.Base, path.BaseName, path.Dir, path.Ext, path.Join, path.Split]
---

`path.Clean` replaces path separators with slashes (`/`) and removes extraneous separators, including trailing separators.

```
{{ path.Clean "foo//bar" }} → "foo/bar"
{{ path.Clean "/foo/bar/" }} → "/foo/bar"
```

On a Windows system, if `.File.Path` is `foo\bar.md`, then:

```
{{ path.Clean .File.Path }} → "foo/bar.md"
```