Limit available web templates in your custom site definition

SharePoint 2010 allows you to create custom web templates or site definitions.
Using the UI, you can limit the available web templates which users are allowed to use if they want to create a new site.

The problem with this is that this is a manual action, to be done after creating a new site. It would be a lot better if the available web templates are always limited without having to do this every time you create a new site.
This is possible and can be done by using a custom site definition or web template where you can specify which templates are allowed. You can specify this in your custom onet.xml.
In this file, you have a Publishing feature with ID {22A9EF51-737B-4FF2-9346-694633FE4416} where you can add a property with the key “AvailableWebTemplates”.AvailableWebTemplatesThe value for this property is a list of web templates.
The format of this list has the following syntax:

“*-{FeatureID}#WebTemplateName1;*-{FeatureID}#WebTemplateName2;”

The FeatureID is the GUID of the feature which contains the definitions for the web templates.
The WebTemplateName can be found in the elements.xml of the web template.

ex.