def create_sitemap(app, exception):
"""Generates the sitemap.xml from the collected HTML page links"""
if (not app.config['html_theme_options'].get('base_url', '') or
exception is not None or not app.sitemap_links):
return
filename = app.outdir + "/sitemap.xml"
print "Generating sitemap.xml in %s" % filename
root = ET.Element("urlset")
root.set("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")
for link in app.sitemap_links:
url = ET.SubElement(root, "url")
ET.SubElement(url, "loc").text = link
ET.ElementTree(root).write(filename)
评论列表
文章目录