Defining Custom Namespaces and Talk Pages

What are the two essential steps required in LocalSettings.php to define a custom namespace and its corresponding ‘Talk’ namespace?

Hi @BlazePlum

To define a custom namespace and its associated “Talk” namespace in LocalSettings.php, you must follow these two essential steps:

1. Assign Unique Constant IDs

You must define two unique integer constants to represent the namespaces. By convention, custom namespaces start at 100 or higher. Crucially, the “Talk” namespace must be the even number immediately following the main namespace.

define( "NS_PROJECT_DATA", 100 );
define( "NS_PROJECT_DATA_TALK", 101 );

2. Register Names in the $wgExtraNamespaces Array

After defining the IDs, you must map them to the actual text strings that will appear in the URL and page titles using the $wgExtraNamespaces global array.

$wgExtraNamespaces[NS_PROJECT_DATA] = "Project_Data";
$wgExtraNamespaces[NS_PROJECT_DATA_TALK] = "Project_Data_talk";

Why the specific numbering?
MediaWiki’s internal logic assumes that for any namespace $N$, the corresponding discussion (Talk) page is $N+1$. If you assign an odd number to your primary custom namespace, the software will fail to link the “Discussion” tab correctly.

Thank you so much for your answer.