Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I did a quick search on the forum about Google Sitemap generation and found a few older posts and was wondering if anyone has any newer ways to generate a Google Sitemap on Umbraco?
Have you tried editing a template in the backoffice, and selecting the option to include one of the Umbraco pre-built macros. I'm sure they have a sitemap in there....
Something like this should do the trick nicely... (I think this even comes built-in):
Layout = null;
//Set to XML
Response.ContentType = "text/xml";
<?xml version="1.0" encoding="UTF-8" ?>
var homePage = CurrentPage.AncestorOrSelf(1);
if (homePage != null && (homePage.Children.Any()))
@helper Traverse(IPublishedContent parent, bool newList)
var subPages = parent.Children.Where(x => x.IsVisible() && !x.HasProperty(DataNodePropertyAlias)).OrderBy(x => x.SortOrder);
foreach (var page in subPages)
private const string DataNodePropertyAlias = "isDataNode";
I tried this and it worked. The only thing I modified was to use "Model.Content.Site()" instead of "CurrentPage.AncestorOrSelf(1)". As suggested here:
Thank you both! I will give this a try! Will update this post with news shortly! :D
Here's a screenshot (in version 7.5.13) of the "Edit Template" screen in the backoffice. If you select the dropdown next to "Insert Inline Razor Macro", you'll see "Sitemap" as one of the options and this will insert the code you need.
Thank you MuirisOG. It is very strange, but in 7.4.14 I do not have the pre-built macros you have. This isn't normal right?
This is what I see:
That is strange.
I've looked back at earlier versions of Umbraco that I have been working on, and found that I have the option under these versions:
6.2.4, 7.3.0, 7.4.3 and 7.5.2
I'm using Webforms, so I don't know if that would cause such a difference.
Here's a screenshot from 6.2.4
This is how I was able to implement a dynamic sitemap on my Umbraco 7.7.9 installation:
Step-by-step tutorial here: https://blog.nicolaayan.com/2018/03/generate-an-umbraco-sitemap/
Hi Bit late to this post, but if anyone is looking for an example of how to do this using a controller, I have a blog post at https://www.georgephillipson.com/blog/umbraco/umbraco-xml-sitemap/ and it also contains code that can be downloaded from GitHub.
Hope it helps someone
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted