-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitemap.xml
More file actions
58 lines (58 loc) · 1.81 KB
/
Copy pathsitemap.xml
File metadata and controls
58 lines (58 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
layout: null
sitemap: false
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>{{ site.url }}{{ site.baseurl }}/</loc>
{%- if site.posts.first %}
<lastmod>{{ site.posts.first.date | date_to_xmlschema }}</lastmod>
{%- endif %}
</url>
{%- for page in site.pages %}
{%- unless page.sitemap == false %}
{%- assign url_parts = page.url | split: "/" %}
{%- assign is_paginated = false %}
{%- if url_parts.size == 3 %}
{%- assign second_part = url_parts[1] %}
{%- if second_part contains "page" %}
{%- assign is_paginated = true %}
{%- endif %}
{%- endif %}
{%- unless is_paginated %}
{%- if page.layout %}
{%- assign page_url = page.url %}
{%- if page_url contains ".html" or page_url == "/" -%}
{%- assign final_url = page_url %}
{%- elsif page_url contains "." -%}
{%- assign final_url = page_url %}
{%- else -%}
{%- assign clean_url = page_url | remove_first: "/" | remove: "/" %}
{%- assign final_url = clean_url | prepend: "/" | append: ".html" %}
{%- endif %}
<url>
<loc>{{ site.url }}{{ site.baseurl }}{{ final_url }}</loc>
{%- if page.last_modified_at %}
<lastmod>{{ page.last_modified_at | date_to_xmlschema }}</lastmod>
{%- elsif page.date %}
<lastmod>{{ page.date | date_to_xmlschema }}</lastmod>
{%- endif %}
</url>
{%- endif %}
{%- endunless %}
{%- endunless %}
{%- endfor %}
{%- for post in site.posts %}
{%- unless post.sitemap == false %}
<url>
<loc>{{ site.url }}{{ site.baseurl }}{{ post.url }}</loc>
{%- if post.last_modified_at %}
<lastmod>{{ post.last_modified_at | date_to_xmlschema }}</lastmod>
{%- else %}
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
{%- endif %}
</url>
{%- endunless %}
{%- endfor %}
</urlset>