Easy Google SiteMaps

For SEO (Search Engine Optimization) you typically want to submit a sitemap in google sitemap protocol format, to google and bing. to help them discover your content.

Since we already build a tree of navigation nodes for the menu, it makes sense that we could and should re-use that existing data to build our xml sitemap for google. There are 2 additional cloudscribe components that make that possible. You would add these packages to your dependencies in your .csproj file"

<PackageReference Include="cloudscribe.Web.SiteMap" Version="1.2.*" />
<PackageReference Include="cloudscribe.Web.SiteMap.FromNavigation" Version="1.2.*" />

The first package cloudscribe.Web.SiteMap (NuGet | GitHub) provides a controller that renders the xml. It takes a constructor dependency on IEnumerable of ISiteMapNodeService, so you could inject as many custom implementations of that as you need and they will all be used to add items to the google sitemap.

The second package cloudscribe.Web.SiteMap.FromNavigation (NuGet | GitHub), provides NavigationTreeSiteMapNodeService, which is an implementation of ISiteMapNodeService that provides data using the same tree we built for the menu and navigation.

Note that if you are using cloudscribe SimpleContent, these things are already wired up for you, and additionally, cloudscribe SimpleContent also provides BlogSiteMapNodeService, to add blog posts to the google sitemap, since blogs are not menu items.

If you are not using cloudscribe SimpleContent, then you would add the packages and then in ConfigureServices of your  Startup.cs you would add this:

services.AddScoped<ISiteMapNodeService, NavigationTreeSiteMapNodeService>();

Note that NavigationTreeSiteMapService is only going to include menu nodes that are not protected by view roles, so your administrative page urls will not be submitted to search engines, only public pages will be included.

Submit Your Sitemap to Google and Bing

The url for your sitemap will be yourdomain/api/sitemap, so for example the sitemap on this site is https://www.cloudscribe.com/api/sitemap. You would submit your url using google webmaster tools and Bing webmaster tools.