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?
Go to SEO > General > Features. Make sure the “XML sitemaps” toggle is on. You should now see your sitemap (or sitemap index) at either yourdomain.com/sitemap.xml or yourdomain.com/sitemap_index.xml.
A sitemap is a file that provides search engines data about the pages of your site. If you're using a content management system (CMS), your sitemap needs to be kept up to date as you add new content/pages.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With