Skip to content

Commit 69ed52a

Browse files
committed
Update python-sitemap.py
1 parent 0d788f0 commit 69ed52a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

python-sitemap.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def generate_sitemap():
1313
post = frontmatter.load(file_path)
1414
if 'permalink' in post:
1515
urls.append(f"{base_url}/{post['permalink']}")
16+
else:
17+
# Generate URL from file path if no permalink
18+
relative_path = file_path.relative_to(Path("_posts/python"))
19+
url_path = relative_path.with_suffix('')
20+
urls.append(f"{base_url}/python/{url_path}")
1621
except:
1722
pass
1823

@@ -21,6 +26,11 @@ def generate_sitemap():
2126
post = frontmatter.load(file_path)
2227
if 'permalink' in post:
2328
urls.append(f"{base_url}/{post['permalink']}")
29+
else:
30+
# Generate URL from file path if no permalink
31+
relative_path = file_path.relative_to(Path("_posts/python"))
32+
url_path = relative_path.with_suffix('')
33+
urls.append(f"{base_url}/python/{url_path}")
2434
except:
2535
pass
2636

0 commit comments

Comments
 (0)