Copied to clipboard

Flag this post as spam?

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


  • Daljit Kaur 16 posts 87 karma points
    Oct 30, 2020 @ 13:13
    Daljit Kaur
    0

    Multilingual sitemaps using Friendly Sitemap Package

    Hello, I am using following package for creating dynamic sitemaps for my multilingual site. https://our.umbraco.com/packages/website-utilities/friendly-sitemap/

    The package is super good and easy to use. The only problem i am getting is that it is only creating sitemaps for my default language.

    e.g http://www.example.com/sitemap.xml is giving me sitemap for english(default) content.

    But when i try to get sitemap for, lets say, swedish site http://www.example.com/sw/sitemap.xml. It is giving 404 error.

    Can i get a single sitemap.xml file for all the links for both english as well as swedish site.

    Kindly Help.

  • Marc Goodson 2157 posts 14411 karma points MVP 9x c-trib
    Oct 31, 2020 @ 10:46
    Marc Goodson
    1

    Hi Anonymous

    It looks like the package is handling the request to /robots.txt by creating a custom route:

    https://github.com/callumbwhyte/friendly-sitemap/blob/dev/src/Our.Umbraco.FriendlySitemap/Startup/SitemapRouteComponent.cs

    public const string SitemapRouteUrl = "sitemap.xml";
    

    but your Swedish url is /sw/sitemap.xml - and the route isn't setup to handle the request for the sitemap.xml if it isn't in the root of the site... which is why I think you get a 404!

    I think in theory you should be able to add an additional route for the sitemap if it's requested from within a language folder, with your own component:

    using System.Web.Routing; using Our.Umbraco.Extensions.Routing; using Umbraco.Core.Composing; using Umbraco.Web;

    namespace YourSite.Routing { public class LanguageSitemapRouteComponent : IComponent { private readonly IUmbracoContextFactory _umbracoContextFactory;

        public LanguageSitemapRouteComponent(IUmbracoContextFactory umbracoContextFactory)
        {
            _umbracoContextFactory = umbracoContextFactory;
        }
    
        public void Initialize()
        {
            RouteTable.Routes.MapUmbracoRoute(
                "LanguageSiteMapRoute",
                "{0}/robots.txt",
                new
                {
                    controller = "Sitemap",
                    action = "RenderSitemap"
                },
                new RootNodeByDomainRouteHandler(_umbracoContextFactory)
            );
        }
    
        public void Terminate()
        {
    
        }
    }
    

    }

    What I'm not quite sure about 'at a glance' is whether the RootNodeByDomainRouteHandler (available in a different package: https://github.com/callumbwhyte/umbraco-routing-extensions) which has the job of identifying the IPublishedContent content item in Umbraco to associate with the route - will match to the correct part of the site and culture based on your swedish request. (it seems to be it's only using the Uri of the domain to find the node in Umbraco to build the SiteMap from).

    If this is the case you could also create your own VirtualNodeRouteHandler:

    https://github.com/callumbwhyte/umbraco-routing-extensions/blob/dev/src/Our.Umbraco.Extensions.Routing/RootNodeByDomainRouteHandler.cs

    copying the above, but changing the logic to find the correct node and culture for your swedish request, but maybe 'it will just work' - hard to tell without knowing more about your implementation.

    but hopefully this gives you the gist of what is going awry!

    regards

    marc

  • Daljit Kaur 16 posts 87 karma points
    Nov 03, 2020 @ 08:19
    Daljit Kaur
    0

    Thanks Marc. Yes it seems like a bug. https://github.com/callumbwhyte/friendly-sitemap/issues/11#issuecomment-720144082

    Meanwhile, i will do it the conventional way of creating sitemap (using template).

    Just one more query: Now that we have 2 sitemap files, one for english version, other for swedish. Do i submit both the file urls to google or i create one sitemap file for both language's urls. What would be the best approach from SEO point of view ?

    Regards.

  • Marc Goodson 2157 posts 14411 karma points MVP 9x c-trib
    Nov 03, 2020 @ 20:29
    Marc Goodson
    1

    HI Daljit

    Yes, I think that issue confirms the hunch as to why it doesn't work as expected!

    In terms of multi lingual sitemaps, there is always lots of conflicting advice. A site map isn't compulsory... and won't necessarily improve your 'SEO' but it can be useful to tell search engines how often to crawl certain sections of the site, which might mean they come back more often, or focus on the right areas of the site. The sitemap is really easy to 'flag' as something missing on SEO site audit report!

    To me it depends on if the site is a different 'territory' eg might have different content targeting people in different ways on different territories, or is a straight language translation - then they feel like the 'same site'.

    What I tend to do with SEO is look to google webmasters blog for advice and this seems like it might be a good article about how to point to different language specific sitemaps from within a global sitemap...

    https://webmasters.googleblog.com/2012/05/multilingual-and-multinational-site.html

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft