Copied to clipboard

Flag this post as spam?

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


  • Lisa Walsak 9 posts 119 karma points
    May 29, 2018 @ 19:00
    Lisa Walsak
    0

    We are dynamically creating our sitemap, but it doesn't include PDFs. How can we include PDFs from the media directory in the sitemap?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Aug 01, 2018 @ 08:56
    Alex Skrypnyk
    0

    Hi Lisa

    Can you show how do you render sitemap? It should be easy change to the code :)

    THanks,

    Oleksandr

  • Lisa Walsak 9 posts 119 karma points
    Aug 01, 2018 @ 14:49
    Lisa Walsak
    0

    We have a sitemap document type and this is the code in the sitemap.cshtml file:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    @{
        umbraco.library.ChangeContentType("text/xml");
    
        int level = 6;
        var home = @CurrentPage.AncestorOrSelf(1);
        var pages = @home.Descendants().Where("noIndex == false");
        pages = pages.Where("TemplateId > 0");
    }
    
          <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    
        <url>
            <loc>https://@Request.Url.Host/</loc>;
            <lastmod>@home.UpdateDate.ToString("yyyy-MM-ddTHH:mm:00")+00:00</lastmod>
            <priority>1</priority>
        </url>
    
        @foreach (var page in pages)
        {
            if (page.Level <= @level)
            {
                <url>
                    <loc>https://@[email protected]</loc>;
                    <lastmod>@page.UpdateDate.ToString("yyyy-MM-ddTHH:mm:00")+00:00</lastmod>
                    @if (page.Level <= 3)
                    {
                        <priority>0.8</priority>
                    }
                    else
                    {
                        <priority>0.5</priority>
                    }
                </url>
            }
        }
        </urlset>
    

    Hope that helps.

  • Paul 184 posts 646 karma points
    Aug 02, 2018 @ 07:47
    Paul
    0

    You'll need to include a query that includes the content of Umbraco.TypedMedia and then combine it with your page query above.

    I take it you are aware that by promoting the indexing of your sites PDFs in Google that it will mean that some people don't visit your site at all and just go direct to the PDFs in question?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Aug 02, 2018 @ 08:27
    Alex Skrypnyk
    0

    Hi Lisa

    You need to traverse through media items also as Paul told.

    Can you show backend structure of pdfs that you want to add to sitemap?

    Alex

  • Lisa Walsak 9 posts 119 karma points
    Aug 02, 2018 @ 13:07
    Lisa Walsak
    100

    Thanks for the responses. This is no longer an active project so I'm not doing anything further.

Please Sign in or register to post replies

Write your reply to:

Draft