# Sage - Show Current Template file

**URL:** https://discourse.roots.io/t/sage-show-current-template-file/20591
**Category:** sage
**Tags:** blade
**Created:** 2021-04-13T03:07:44Z
**Posts:** 3

## Post 1 by @hallowichig0 — 2021-04-13T03:07:44Z

Hi everyone,

I’m trying to show the current template file or what template file is being used.

I tried this one:

```
add_action('wp_body_open', function () {
    global $template;
    if( current_user_can('administrator') ) {
        echo '<!-- Template File: ' . basename($template) . ' -->';
    }
});
```

But it always shows index.php

I also tried other plugins that will show the current template file but sadly it always returns to index.php

Does anyone know how to solve this issue?  
Thank you

---

## Post 2 by @alwaysblank — 2021-04-13T03:35:45Z

What is the reason you need to know the current template file?

---

## Post 3 by @hallowichig0 — 2021-04-13T04:13:18Z

Good morning sir @alwaysblank , thank you for your reply :slight_smile:

My reason is to easily navigate which file is being used or what blade is being used on every pages or posts, especially when you created a lot of custom templates and custom post types. And this is useful for a large development.

---

## Post 4 by @system — 2021-05-25T03:07:46Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
