Example of how to automatically set Umbraco page template

Example of how to automatically set Umbraco page template

Example of how to ensure content nodes have a default template set in Umbraco 9+ Have you ever been in a situation where a page throws a 404 even though it is there? This sometimes happens when a template has not been set correctly in Umbraco and sometimes the back office shows the template as set but isn't actually until the page is published. This code will iterate over a set of nodes based on the parent key and ensure the template is set and publish the content node.

See the example below: