# Is it possible to get template filename from template?

**URL:** https://discourse.gohugo.io/t/is-it-possible-to-get-template-filename-from-template/32504
**Category:** support
**Created:** [April 24, 2021, 6:16am UTC](https://discourse.gohugo.io/t/is-it-possible-to-get-template-filename-from-template/32504 "2021-04-24T06:16:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fairplay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/fairplay/32/9884_2.png) [@fairplay](https://discourse.gohugo.io/u/fairplay)
#### Post date: [April 24, 2021, 6:16am UTC](https://discourse.gohugo.io/t/is-it-possible-to-get-template-filename-from-template/32504/1 "2021-04-24T06:16:30Z")

</div>

For learning and debug purposes I use following code in each template:

```
{{ if .Site.Params.debug }}
    {{ printf "<!-- Template: taxonomy/list.html -->" | safeHTML }}
{{ end}}

```

Is it possible to achieve same result by reusable code without filename hardcoding? Something like

```
{{ if .Site.Params.debug }}
    {{ printf "<!-- Template: %s -->" .TemplateRelPermalink | safeHTML }}
{{ end}}
```

---

<div class="post-metadata">

### Author: ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)
#### Post date: [April 24, 2021, 10:26am UTC](https://discourse.gohugo.io/t/is-it-possible-to-get-template-filename-from-template/32504/2 "2021-04-24T10:26:47Z")

</div>

> Is it possible to achieve same result by reusable code without filename hardcoding?

Not currently.
