The template object has a handful of attributes.

template.name

Returns the template's name without the template's custom suffix, if it exists, or the .liquid extension.

<!-- If you're on the product.liquid template -->
{{ template.name }}
product

template.type

Returns the enum value of template's type, e.g. 15, 1, 2, 13, 5.

Descriptiontemplate.typetemplate.nameURL
Product detail page1product
Collection page2collection
Custom page3page
Article page4article
Blog page5blog
Search page8search/search
Cart page13cart/cart
Index page15index/
404 page16404/404
Custom page in theme41theme_page
<!-- If you're on the product.liquid template -->
{{ template.type }}
1