How to create a sitemap for your website

First create a page called website and enter this HTML code.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {{ partial | sitemap | arango | aql#FOR page IN pages RETURN page }}
  {{ partial | sitemap_blog | arango | aql#FOR post IN datasets FILTER post.type == 'posts' AND post.online == true  RETURN post }}
</urlset>

As you can see we are running two partials. One for all pages and one for all posts.

Here my partials : The first one is sitemap and the second one is sitemap_blog

<% for k, item in pairs(dataset.results) do %>
  <url>
    <loc>https://fasty.ovh/en/<%=item.slug.en%></loc>
    <lastmod><%=item.published_at%></lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>
<% end %>
<% for k, item in pairs(dataset.results) do %>
  <url>
    <loc>https://fasty.ovh/en/blog/<%=item.slug%></loc>
    <lastmod><%=item.published_at%></lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>
<% end %>

That's it ! Now have a look to the generated XML on your /en/sitemap page

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  
  <url>
    <loc>https://fasty.ovh/en/talk</loc>
    <lastmod>2019-05-22</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/sub</loc>
    <lastmod>2019-05-23</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/pricing</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/rss</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/contentful-demo</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/my-404error-page</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/post</loc>
    <lastmod>2019-06-20</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/documentation</loc>
    <lastmod>2019-06-23</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/home</loc>
    <lastmod>2019-03-15</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/sitemap</loc>
    <lastmod>nil</lastmod>
    <changefreq>daily</changefreq>
    <priority>1</priority>
  </url>

  
  <url>
    <loc>https://fasty.ovh/en/blog/4333926-added-a-new-datatype-definition-attribute-publishable-to-allow-some-workflow</loc>
    <lastmod>2019-06-13</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/4333981-the-npm-fasty-cli-allow-you-now-to-lock-your-files-no-one-will-overwrite-your-modifications</loc>
    <lastmod>2019-06-20</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/5664106-edit-server-side-scripts-within-fasty-edit-save-restart</loc>
    <lastmod>2019-07-18</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/6532549-fix-drag-drop-html-code-on-editor</loc>
    <lastmod>2019-08-04</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/7013864-removed-redirection-for-root-path-to-a-quicker-page-rendering</loc>
    <lastmod>2019-08-15</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/7541122-set-dynamic-headers-via-og-data-key-shortcut-and-an-aql-request-per-page</loc>
    <lastmod>2019-08-25</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/7787706-using-the-api-builder</loc>
    <lastmod>2019-08-31</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/8042003-le-vitaliseur-de-marion-s-blog-is-running-on-fasty</loc>
    <lastmod>2019-09-05</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/8168308-why-we-chose-openresty-lua-lapis-arangodb</loc>
    <lastmod>2019-09-07</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/10944880-add-params-to-helper-shortcut</loc>
    <lastmod>2019-09-27</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/13111325-define-your-404-error-pages-with-your-own-content</loc>
    <lastmod>2019-10-20</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/14183204-the-i-18-n-feature</loc>
    <lastmod>2019-11-01</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/17618520-page-builders</loc>
    <lastmod>2019-12-08</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/18914906-does-fasty-is-a-headless-cms</loc>
    <lastmod>2019-12-21</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/19385192-a-new-website-powered-by-fasty</loc>
    <lastmod>2019-12-26</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/21338848-how-to-build-simple-page-applications</loc>
    <lastmod>2020-01-02</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/21753683-web-components</loc>
    <lastmod>2020-01-04</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/24867034-how-to-create-pagination</loc>
    <lastmod>2020-01-14</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

  <url>
    <loc>https://fasty.ovh/en/blog/26183747-fasty-api</loc>
    <lastmod>2020-01-19</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
  </url>

</urlset>

Leave a comment