Skip to content

Commit db482ef

Browse files
authored
Update generate_sitemap.py
1 parent 9f568ff commit db482ef

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

generate_sitemap.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,14 @@ def encode_url(url):
5353
"""Encode the URL to make it XML-safe and RFC-compliant."""
5454
return quote(url, safe=":/?&=") # Leave common URL-safe characters untouched
5555

56-
def add_static_urls(root, urls):
57-
"""Add static URLs to the sitemap."""
56+
def add_static_urls_without_translations(root, urls):
57+
"""Add static URLs without translations to the sitemap."""
5858
for url in urls:
5959
url_element = ET.Element('{http://www.sitemaps.org/schemas/sitemap/0.9}url')
6060

6161
loc = ET.SubElement(url_element, '{http://www.sitemaps.org/schemas/sitemap/0.9}loc')
6262
loc.text = encode_url(url)
6363

64-
# Add translations for each language
65-
for lang_code, hreflang in languages.items():
66-
translated_url = encode_url(f"{url}/{lang_code}")
67-
alt_link = ET.SubElement(url_element, '{http://www.w3.org/1999/xhtml}link')
68-
alt_link.set('rel', 'alternate')
69-
alt_link.set('hreflang', hreflang)
70-
alt_link.set('href', translated_url)
71-
7264
root.append(url_element)
7365

7466
def main():
@@ -101,7 +93,7 @@ def main():
10193
loc.text = encode_url("https://www.hacktricks.xyz/")
10294
new_root.append(static_url)
10395

104-
# Add static URLs for training.hacktricks.xyz
96+
# Add static URLs for training.hacktricks.xyz without translations
10597
static_training_urls = [
10698
"https://training.hacktricks.xyz/",
10799
"https://training.hacktricks.xyz/courses/arte",
@@ -116,7 +108,7 @@ def main():
116108
"https://training.hacktricks.xyz/terms",
117109
"https://training.hacktricks.xyz/privacy",
118110
]
119-
add_static_urls(new_root, static_training_urls)
111+
add_static_urls_without_translations(new_root, static_training_urls)
120112

121113
# Process main URLs
122114
for url_element in tqdm(all_urls, desc="Processing URLs"):

0 commit comments

Comments
 (0)