In SharePoint 2013 when you create a new page under a publishing page it adds a new Term under the "site navigation" termset of the site collection. What I want to do, is having more control on where this term is created. I want to prevent it to be created directly under the "Site Navigation" termset, but under the site's term. I was wandering to create a feature to do it for me but I have two problems, 1. I dont know where I need to assign the navigation type and the friendly url. 2. How do I prevent SharePoint to do it for me.
There are some options available for you under Site settings -> Navigation. For example, in the "Managed Navigation: Term Set" section, you can specify term set different from 'Site Navigation', and from now on your new pages will get terms in that term set. You can also uncheck "Create friendly URLs for new pages automatically" and "Add new pages to navigation automatically", and if you do that, no new terms will be created for new pages added by you in the Term Store.
Also, after a term is created, you can always move it to the required location using either Term Store manager or an object model. If you have too many terms, you can always write a piece of code (e.g. powershell script) to bulk move all the terms. This page has some information to help you get started http://msdn.microsoft.com/en-us/library/jj163949.aspx
In order to add new terms to navigation term set, you can use the following code:
// Obtain navigation term set NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web, "GlobalNavigationTaxonomyProvider"); // Specify that this term set can be used for site navigation navigationTermSet.IsNavigationTermSet = true; // Creates new term pointing to an already existing URL outside of SharePoint NavigationTerm term = navigationTermSet.CreateTerm("Bing Search", NavigationLinkType.SimpleLink, Guid.NewGuid()); term.SimpleLinkUrl = "http://www.bing.com/"; // Creates new term pointing to an existing SharePoint page NavigationTerm term2 = navigationTermSet.CreateTerm("Target page", NavigationLinkType.FriendlyUrl, Guid.NewGuid()); term2.TargetUrl.Value = "~site/Pages/TargetPage.aspx";