Manual:$wgNonincludableNamespaces

Pages in namespaces in this array cannot be used as templates. Elements must be numeric namespace IDs or namespace constants. Among other things, this may be useful to enforce read-restrictions that may otherwise be bypassed by using the template mechanism.

or