How to build sitemap.xml for AngularJS website?
Asked Answered
S

2

8

I have setup an AngularJS application which is using ui-state router. It has some static pages and other than that it has profile pages which generate dynamic page based on profile id.

For SEO purpose I have used PhantomJS and generate HTMLs to give crawler response.

But, How can I generate sitemap.xml which contains all the dynamic pages URL and by that crawler can fetch and list on search engine?

Schistosome answered 14/11, 2016 at 14:42 Comment(0)
N
2

Using JavaScript

You can use XMLWriter to create an XML. Then you can pass this XML as a string to your web server. Check this out for XML Writer.

Here is a tutorial for the available methods for writing an XML using XMLWriter - Tutorial

Using Nodejs

You can write a node js function for generating the sitemap from the generated URLs. Please refer to this link for a sample.

The better way is to create a script in the backend to generate it periodically to update sitemaps. Query the tables, create URLs and generate XML files. You can configure cron jobs in the server to generate the sitemaps periodically.

There will be libraries and tutorials available for each BE technology for generating the sitemap.

For example:

Ruby on Rails - Nokogiri
Elixir - sitemap
.Net - Tutorial
Java - Tutorial
Express JS - express-sitemap

Nev answered 27/11, 2018 at 6:12 Comment(0)
C
-1

Simple, You need to generate online Sitemap that creates all dynamic URLs. Just Search Online Sitemap Generator. put your Website URL and it creates the Sitemap.XML file, You need to download that file and upload in your server.

after that check that Sitemap using www.mydomain.com/sitemap.xml

Crinkumcrankum answered 27/11, 2018 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.