Template:NAMESPACEID/doc

Returns the namespace ID of page given, or of the current page.

Usage

 * → (Main namespace)
 * → (Main namespace)
 * → (Main namespace)

Namespace aliases are accepted, too:

Invalid input returns an error, which can be caught with the #iferror parser function: