Template:Error:not substituted/doc

In a template that must be substituted, add the following code at the top (replacing "template name" appropriately):

{{#ifeq:{{<includeonly>subst:</includeonly>PAGENAME}}|{{PAGENAME}}||{{error:not substituted|template name}}}}

See also an explanation of how it works.