A template must have the isTemplate system attribute in the <aura:component> tag set to true. This informs the framework to allow restricted items, such as <script> tags, which aren't allowed in regular components.
For example, a sample app has a np:template template that extends aura:template. np:template looks like:
<aura:component isTemplate="true" extends="aura:template"> <aura:set attribute="title" value="My App"/> ... </aura:component>
Note how the component extends aura:template and sets the title attribute using aura:set.
The app points at the custom template by setting the template system attribute in <aura:application>.
<aura:application template="np:template"> ... </aura:application>
A template can only extend a component or another template. A component or an application can't extend a template.