tyrel.cloud


All posts tagged:


Lektor Sitemap

Updated by Tyrel on 2021-12-03

Summary

A sitemap lists a website's pages, helping search engines find and crawl them.

How to get a working sitemap.xml

Official Guide: https://www.getlektor.com/docs/guides/sitemap/

  1. Create sitemap.xml directory in the content directory
  2. Add contents.lr to the sitemap.xml directory containing:
     _template: sitemap.xml
    ---
     _model: none
    
  3. Create a template file sitemap.xml in the templates directory, this file should contain:

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    {%- for page in [site.root] if page != this recursive %}
    <url><loc>{{ page|url(external=true) }}</loc></url>
    {{- loop(page.children|sort(attribute='path')) }}
    {%- endfor %}
    </urlset>
    
  4. Configure the url of the site in the main project file tyrel.cloud.lektorproject

    [project]
    name = tyrel.cloud
    url = https://www.tyrel.cloud/
    

Done!

At this point you may want to go to your search engine and upload your sitemap... https://search.google.com/search-console/sitemaps?

Feel like I missed something? Let me know in the comments!