How to let sitemap generator fully crawl Angular router for SPA?

前端 未结 1 1636
眼角桃花
眼角桃花 2021-02-19 08:46

I am trying to generate a sitemap for my webpage.

The sitemap generators online only show me a homepage on xml file.



        
相关标签:
1条回答
  • 2021-02-19 09:20

    As Karl the Botmap.io developer answers the question the crawler only supports href links.

    Hi! Do your links/anchor tags have an href attribute? The bot currently only detects and crawls the href attribute. You can add it even if your angular app doesn't use it internally. It may be redundant, however it may work as a stopgap until I can update the bot to handle this scenario.

    Since Im using routerlinks and I don't want to change my code using hrefs I decided to manually create Sitemap.

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url><loc>http://margvel.com</loc><priority>0.5</priority></url>
    <url><loc>http://margvel.com/projects</loc><priority>0.5</priority></url>
    <url><loc>http://margvel.com/jobs</loc><priority>0.5</priority></url>
    <url><loc>http://margvel.com/education</loc><priority>0.5</priority></url>
    <url><loc>http://margvel.com/resume</loc><priority>0.5</priority></url>
    <url><loc>http://margvel.com/contact</loc><priority>0.5</priority></url>
    </urlset>
    

    All I did was went through the routes in angular and put them in xml file like displayed above.

    I gave all the links priority 0.5 since it is the manual priority chosen between 0 - 1.0 . I didn't have any preference for pages.

    NOTE - This approach is only for small sitemaps with small amount of pages.

    0 讨论(0)
提交回复
热议问题