def sitemap(): """Generate sitemap.xml """ pages = [] # All pages registed with flask apps for rule in app.url_map.iter_rules(): if "GET" in rule.methods and len(rule.arguments) == 0: pages.append(rule.rule) sitemap_xml = render_template('sitemap_template.xml', pages=pages) response = make_response(sitemap_xml) response.headers["Content-Type"] = "application/xml" return response
Thursday, July 25, 2013
Generate sitemap using Flask
It's quite easy to generate a sitemap using Flask route map. You can refer this link to see the idea how to generate a sitemap.xml. The code below is my implementation for my website.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment