Satchel
Satchel

Reputation: 16734

How can I generate sitemaps on heroku?

I've seen some older threads on generating a sitemap on heroku...the challenges being it needs to be stored on S3 and configuring it so that the sitemap is legitimate since it is hosted elsewhere.

I didn't see anything definitive, however, some conversations and suggested patches.

Is there something out-of-the-box that can work well with heroku?

Upvotes: 3

Views: 3988

Answers (4)

garam hyeon
garam hyeon

Reputation: 139

I can't speak English not well. But explan to you my code. xml is create using 'xmlbuilder'.

CreateXmlFile(request, response, next, function(request, response, next, xml){
      response.type('text/xml');
      response.send(xml);
      if(typeof next == "function"){
        next();
      }
    });

Upvotes: 0

kinopyo
kinopyo

Reputation: 1687

Based on the article of https://github.com/kjvarga/sitemap_generator

You should add the URL of the sitemap index file to public/robots.txt to help search engines >find your sitemaps. The URL should be the complete URL to the sitemap index. For example:

Sitemap: http://www.example.com/sitemap_index.xml.gz

If you're using google webmaster tools, which only allowing you to specify a url of your host, maybe you can create a controller & action to just redirect to the sitemap.xml on your S3. And then specify that url in webmaster tools. http://www.billrowell.com/2012/02/01/create-an-xml-sitemap-on-heroku-via-amazon-s3/

If you are looking for uploading to S3, this should help: https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku

Upvotes: 10

Satchel
Satchel

Reputation: 16734

I am awaiting for the s3 version of sitemap_generator and if it does what it says, that should be it.

Upvotes: 1

John Beynon
John Beynon

Reputation: 37507

I've previously done this via route named sitemap.xml to a controller that builds a sitemap dynamically - rather than scraping the site and having a hard coded sitemap.xml that has to be stored somewhere. I guess it depends on your app and the frequency at which the URLs are changing.

Upvotes: 1

Related Questions