Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Biagio Paruolo 1593 posts 1824 karma points c-trib
    Mar 19, 2016 @ 16:11
    Biagio Paruolo
    1

    SEO Sitemap : How to include categories and products?

    Hi,

    I create a SEO sitemap, but how to include Product groups and products? I see that sitemap stop to store. Here an example: http://www.fondosanitario.com/sitemap

    Thanks

  • Aristotelis Pitaridis 84 posts 402 karma points
    Mar 19, 2016 @ 19:43
    Aristotelis Pitaridis
    0

    Try my CM Umbraco Tools where I have a tool for automatic generation of sitemap. It also has filters to exclude specific contents or contents with a specific alias name or use a custom property in the document type which will define if a content should be included or not in the sitemap.

    https://our.umbraco.org/projects/developer-tools/cm-umbraco-tools/

  • Biagio Paruolo 1593 posts 1824 karma points c-trib
    Mar 20, 2016 @ 08:46
    Biagio Paruolo
    0

    I'll give a try. Thank you.

  • Michelle Topp 33 posts 143 karma points
    Jul 27, 2017 @ 14:23
    Michelle Topp
    1

    Hi all,

    Managed to create a helper query that I just added to a basic sitemap view to add the products to the site map.

    @inherits Merchello.Web.Mvc.MerchelloTemplatePage
    @using Merchello.Core.Models
    @using Merchello.FastTrack.Ui
    @using Merchello.Web
    @using Merchello.Web.Models.ContentEditing;
    @using Our.Umbraco.Ditto;
    @using System.Configuration;
    @{
        Layout = null;
    }<?xml version="1.0" encoding="UTF-8" ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
            xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
        <url>
            <loc>@(Model.Content.AncestorOrSelf(1).UrlWithDomain())</loc>
            <lastmod>@Model.Content.AncestorOrSelf(1).UpdateDate.ToString("s")+00:00</lastmod>
        </url>
        @ListChildNodes(Model.Content.AncestorOrSelf(1))
        @ListProductNodes()
    </urlset>
    
    @helper ListChildNodes(IPublishedContent startNode)
    {
        Response.ContentType = "text/xml";
        const int maxLevelForSiteMap = 100;
        foreach (var node in startNode.Children
            .Where(n =>
                //n.IsVisible() &&
                n.TemplateId > 0 &&
                !Umbraco.IsProtected(n.Path) &&
                (!n.HasProperty("searchEngineSiteMapHide") || !n.GetPropertyValue<bool>("searchEngineSiteMapHide")))
            .Select(n => n.AsDynamic()))
            {
                    <url>
                    <loc>@(((IPublishedContent)node).UrlWithDomain())</loc>
                    <lastmod>@node.UpdateDate.ToString("s")+00:00</lastmod>
                    @if (node.SearchEngineSitemapChangeFreq.ToString() != "")
                    {<changefreq>@node.SearchEngineSitemapChangeFreq</changefreq>}
                    @if (node.SearchEngineSitemapPriority.ToString() != "")
                    {<priority>@node.SearchEngineSitemapPriority</priority>}
                </url>
            if (node.Level <= maxLevelForSiteMap)
            {
                    @ListChildNodes(node)
            }
        }
    }
    
    @helper ListProductNodes()
    {
        var merchelloHelper = new MerchelloHelper();
        var products = merchelloHelper.Query.Product.Search(1, 1000);
    
        var queryProducts = products.Items.Select(x => (ProductDisplay)x).Where(x => x.Available == true);
    
        foreach (var product in queryProducts)
        {
            var node = merchelloHelper.Query.Product.TypedProductContent(product.Key);
    
            <url>
                <loc>@String.Format("{0}/{1}", ConfigurationManager.AppSettings["SiteUrl"], @node.Url)</loc>
                <lastmod>@node.UpdateDate.ToString("s")+00:00</lastmod>          
            </url>
        }
    }
    

    Hope this helps anyone that needs it.

Please Sign in or register to post replies

Write your reply to:

Draft