How to: manage SharePoint 2013 navigation settings in c#

I recently needed to manage SharePoint 2013’s navigation settings from code (c#) because we were deploying a custom web template.

Believe me, there are a bunch of different objects you need to use depending on which setting you are trying to edit.

  • web.Navigation (Namespace: Microsoft.SharePoint)
  • publishingWeb.Navigation (Namespace: Microsoft.SharePoint.Publishing)
  • WebNavigationSettings (Namespace: Microsoft.SharePoint.Publishing.Navigation)

After a lot of search, I found an incredible article by Johannes Milling on the subject. Check it out here:

Once again, I hope it saves someone some time!