Template:TEMPLATENAME/doc

When used on a template's /doc subpage, {{TEMPLATENAME}} evaluates to the name of the associated template. The result will be accurate when the end page is either the /doc subpage or the actual template page. The template makes a special case for the Template: namespace: the Template: prefix will be removed.

Note that the result will not be URL-safe. For a URL-encoded version, see {{TEMPLATENAMEE}}.