Search code examples
google-app-enginegwtseosearch-enginesitemap

Dynamic sitemap generation for GWT based appengine website


We are aware of the appengine limitation relating to writing files to disk. So the idea of having a dynamic sitemap via i/o seems a bit difficult for AppEngine. So here are some ideas that we wish to validate:

  1. Can we have a servlet that generates a google sitemap compatible xml dynamically?
  2. If this is possible, can someone share an example?
  3. Can such a sitemap, in turn, contain dynamic links that return raw textual data suitable for indexing?
  4. If the above is true, the only problem we see is that, such dynamic URLs, that are only meant for indexing content, will become available in search results. Instead we wish that users land directly on the homepage of the website.
  5. With respect to SEO, given that the website is pure GWT, is there a better way to index content?

Solution

  • For dynamic URLs your only solution since you are using Java on Google App Engine is to create a servlet that will create this response.

    There are many libraries that you can use that will make sure that your XML is correct but the simplest example that can get you started will look like this:

    public class SitemapsServlet extends HttpServlet {
        public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
            resp.setContentType("application/xml");
            resp.getWriter().println("<?xml version="1.0" encoding="UTF-8"?>");
            resp.getWriter().println("<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">");
            resp.getWriter().println("  <url>");
            resp.getWriter().println("    <loc>http://www.example.com/?id=who</loc>");
            resp.getWriter().println("    <lastmod>2009-09-22</lastmod>");
            resp.getWriter().println("    <changefreq>monthly</changefreq>");
            resp.getWriter().println("    <priority>0.8</priority>");
            resp.getWriter().println("  </url>");
            resp.getWriter().println("</urlset>");
        }
    }
    

    For the rest of the questions make sure that you understand how the sitemaps are working and what's their purpose.