Skip to content

Commit 16671ed

Browse files
author
TechStack Global
committed
fix(seo): strictly format sitemap.xml for Google Search Console compliance (LF, double quotes, absolute URL matching)
1 parent 3ef7bf9 commit 16671ed

File tree

2 files changed

+85
-75
lines changed

2 files changed

+85
-75
lines changed

generate_sitemap.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,27 @@ def main():
1919
date_str = datetime.now().strftime('%Y-%m-%d')
2020
sitemap_path = os.path.join(BASE_DIR, 'sitemap.xml')
2121

22+
# Strictly formatted XML declaration with double quotes
2223
xml_content = '<?xml version="1.0" encoding="UTF-8"?>\n'
2324
xml_content += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
2425

25-
html_files = get_html_files()
26+
html_files = sorted(get_html_files()) # Sorted for consistency
2627

2728
for f in html_files:
2829
rel_path = os.path.relpath(f, BASE_DIR).replace('\\', '/')
30+
# Exclude technical or irrelevant files
31+
if rel_path in ['404.html', 'thank-you.html', 'google50e160eb06944afd.html']:
32+
continue
33+
34+
url = f"{BASE_URL}/{rel_path}"
35+
# Priority mapping
2936
if rel_path == 'index.html':
30-
url = f"{BASE_URL}/"
3137
priority = "1.0"
3238
elif rel_path == 'blog.html':
33-
url = f"{BASE_URL}/{rel_path}"
3439
priority = "0.9"
3540
elif rel_path.startswith('posts/'):
36-
url = f"{BASE_URL}/{rel_path}"
3741
priority = "0.8"
3842
else:
39-
url = f"{BASE_URL}/{rel_path}"
4043
priority = "0.6"
4144

4245
xml_content += f' <url>\n'
@@ -46,9 +49,10 @@ def main():
4649
xml_content += f' <priority>{priority}</priority>\n'
4750
xml_content += f' </url>\n'
4851

49-
xml_content += '</urlset>\n'
52+
xml_content += '</urlset>' # No trailing newline for maximum compatibility
5053

51-
with open(sitemap_path, 'w', encoding='utf-8') as f:
54+
# Write with LF (line_buffering=False and newline='\n')
55+
with open(sitemap_path, 'w', encoding='utf-8', newline='\n') as f:
5256
f.write(xml_content)
5357

5458
print(f"Sitemap generated at {sitemap_path}")

sitemap.xml

Lines changed: 74 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,243 +1,249 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3-
<url>
4-
<loc>https://techstackglobal.github.io/</loc>
5-
<lastmod>2026-03-06</lastmod>
6-
<changefreq>monthly</changefreq>
7-
<priority>1.0</priority>
8-
</url>
9-
<url>
10-
<loc>https://techstackglobal.github.io/blog.html</loc>
11-
<lastmod>2026-03-06</lastmod>
12-
<changefreq>monthly</changefreq>
13-
<priority>0.9</priority>
14-
</url>
153
<url>
164
<loc>https://techstackglobal.github.io/about.html</loc>
17-
<lastmod>2026-03-05</lastmod>
5+
<lastmod>2026-03-07</lastmod>
186
<changefreq>monthly</changefreq>
197
<priority>0.6</priority>
208
</url>
219
<url>
2210
<loc>https://techstackglobal.github.io/affiliate-disclosure.html</loc>
23-
<lastmod>2026-03-05</lastmod>
11+
<lastmod>2026-03-07</lastmod>
2412
<changefreq>monthly</changefreq>
2513
<priority>0.6</priority>
2614
</url>
2715
<url>
2816
<loc>https://techstackglobal.github.io/amazon-stack.html</loc>
29-
<lastmod>2026-03-05</lastmod>
17+
<lastmod>2026-03-07</lastmod>
3018
<changefreq>monthly</changefreq>
3119
<priority>0.6</priority>
3220
</url>
3321
<url>
34-
<loc>https://techstackglobal.github.io/contact.html</loc>
35-
<lastmod>2026-03-05</lastmod>
36-
<changefreq>monthly</changefreq>
37-
<priority>0.6</priority>
38-
</url>
39-
<url>
40-
<loc>https://techstackglobal.github.io/privacy-policy.html</loc>
41-
<lastmod>2026-03-05</lastmod>
22+
<loc>https://techstackglobal.github.io/blog.html</loc>
23+
<lastmod>2026-03-07</lastmod>
4224
<changefreq>monthly</changefreq>
43-
<priority>0.6</priority>
25+
<priority>0.9</priority>
4426
</url>
4527
<url>
46-
<loc>https://techstackglobal.github.io/terms-of-service.html</loc>
47-
<lastmod>2026-03-05</lastmod>
28+
<loc>https://techstackglobal.github.io/contact.html</loc>
29+
<lastmod>2026-03-07</lastmod>
4830
<changefreq>monthly</changefreq>
4931
<priority>0.6</priority>
5032
</url>
5133
<url>
52-
<loc>https://techstackglobal.github.io/posts/best-headphones-for-online-classes-2026.html</loc>
53-
<lastmod>2026-03-06</lastmod>
34+
<loc>https://techstackglobal.github.io/index.html</loc>
35+
<lastmod>2026-03-07</lastmod>
5436
<changefreq>monthly</changefreq>
55-
<priority>0.8</priority>
37+
<priority>1.0</priority>
5638
</url>
5739
<url>
58-
<loc>https://techstackglobal.github.io/posts/best-ultrawide-monitor-for-programming-2026.html</loc>
59-
<lastmod>2026-03-06</lastmod>
40+
<loc>https://techstackglobal.github.io/posts/alienware-aw3423dwf-review.html</loc>
41+
<lastmod>2026-03-07</lastmod>
6042
<changefreq>monthly</changefreq>
6143
<priority>0.8</priority>
6244
</url>
6345
<url>
64-
<loc>https://techstackglobal.github.io/posts/best-microphones-for-remote-work-2026.html</loc>
65-
<lastmod>2026-03-06</lastmod>
46+
<loc>https://techstackglobal.github.io/posts/alienware-aw3423dwf-vs-odyssey-g8.html</loc>
47+
<lastmod>2026-03-07</lastmod>
6648
<changefreq>monthly</changefreq>
6749
<priority>0.8</priority>
6850
</url>
6951
<url>
70-
<loc>https://techstackglobal.github.io/posts/best-headphones-for-zoom-meetings-2026.html</loc>
71-
<lastmod>2026-03-06</lastmod>
52+
<loc>https://techstackglobal.github.io/posts/apple-macbook-pro-m4-pro-review.html</loc>
53+
<lastmod>2026-03-07</lastmod>
7254
<changefreq>monthly</changefreq>
7355
<priority>0.8</priority>
7456
</url>
7557
<url>
76-
<loc>https://techstackglobal.github.io/posts/alienware-aw3423dwf-review.html</loc>
77-
<lastmod>2026-03-05</lastmod>
58+
<loc>https://techstackglobal.github.io/posts/best-headphones-for-online-classes-2026.html</loc>
59+
<lastmod>2026-03-07</lastmod>
7860
<changefreq>monthly</changefreq>
7961
<priority>0.8</priority>
8062
</url>
8163
<url>
82-
<loc>https://techstackglobal.github.io/posts/alienware-aw3423dwf-vs-odyssey-g8.html</loc>
83-
<lastmod>2026-03-05</lastmod>
64+
<loc>https://techstackglobal.github.io/posts/best-headphones-for-remote-work-2026.html</loc>
65+
<lastmod>2026-03-07</lastmod>
8466
<changefreq>monthly</changefreq>
8567
<priority>0.8</priority>
8668
</url>
8769
<url>
88-
<loc>https://techstackglobal.github.io/posts/apple-macbook-pro-m4-pro-review.html</loc>
89-
<lastmod>2026-03-05</lastmod>
70+
<loc>https://techstackglobal.github.io/posts/best-headphones-for-zoom-meetings-2026.html</loc>
71+
<lastmod>2026-03-07</lastmod>
9072
<changefreq>monthly</changefreq>
9173
<priority>0.8</priority>
9274
</url>
9375
<url>
94-
<loc>https://techstackglobal.github.io/posts/best-headphones-for-remote-work-2026.html</loc>
95-
<lastmod>2026-03-05</lastmod>
76+
<loc>https://techstackglobal.github.io/posts/best-laptops-for-students-2026.html</loc>
77+
<lastmod>2026-03-07</lastmod>
9678
<changefreq>monthly</changefreq>
9779
<priority>0.8</priority>
9880
</url>
9981
<url>
100-
<loc>https://techstackglobal.github.io/posts/best-laptops-for-students-2026.html</loc>
101-
<lastmod>2026-03-05</lastmod>
82+
<loc>https://techstackglobal.github.io/posts/best-microphones-for-remote-work-2026.html</loc>
83+
<lastmod>2026-03-07</lastmod>
10284
<changefreq>monthly</changefreq>
10385
<priority>0.8</priority>
10486
</url>
10587
<url>
10688
<loc>https://techstackglobal.github.io/posts/best-noise-cancelling-headphones-2026.html</loc>
107-
<lastmod>2026-03-05</lastmod>
89+
<lastmod>2026-03-07</lastmod>
10890
<changefreq>monthly</changefreq>
10991
<priority>0.8</priority>
11092
</url>
11193
<url>
11294
<loc>https://techstackglobal.github.io/posts/best-podcast-microphones-2026.html</loc>
113-
<lastmod>2026-03-05</lastmod>
95+
<lastmod>2026-03-07</lastmod>
11496
<changefreq>monthly</changefreq>
11597
<priority>0.8</priority>
11698
</url>
11799
<url>
118100
<loc>https://techstackglobal.github.io/posts/best-premium-laptop-for-work-2026.html</loc>
119-
<lastmod>2026-03-05</lastmod>
101+
<lastmod>2026-03-07</lastmod>
120102
<changefreq>monthly</changefreq>
121103
<priority>0.8</priority>
122104
</url>
123105
<url>
124106
<loc>https://techstackglobal.github.io/posts/best-remote-work-setup-2026.html</loc>
125-
<lastmod>2026-03-05</lastmod>
107+
<lastmod>2026-03-07</lastmod>
126108
<changefreq>monthly</changefreq>
127109
<priority>0.8</priority>
128110
</url>
129111
<url>
130112
<loc>https://techstackglobal.github.io/posts/best-ultrawide-monitor-for-productivity-2026.html</loc>
131-
<lastmod>2026-03-05</lastmod>
113+
<lastmod>2026-03-07</lastmod>
114+
<changefreq>monthly</changefreq>
115+
<priority>0.8</priority>
116+
</url>
117+
<url>
118+
<loc>https://techstackglobal.github.io/posts/best-ultrawide-monitor-for-programming-2026.html</loc>
119+
<lastmod>2026-03-07</lastmod>
132120
<changefreq>monthly</changefreq>
133121
<priority>0.8</priority>
134122
</url>
135123
<url>
136124
<loc>https://techstackglobal.github.io/posts/best-ultrawide-monitors-2026.html</loc>
137-
<lastmod>2026-03-05</lastmod>
125+
<lastmod>2026-03-07</lastmod>
138126
<changefreq>monthly</changefreq>
139127
<priority>0.8</priority>
140128
</url>
141129
<url>
142130
<loc>https://techstackglobal.github.io/posts/bose-qc-ultra-review.html</loc>
143-
<lastmod>2026-03-05</lastmod>
131+
<lastmod>2026-03-07</lastmod>
144132
<changefreq>monthly</changefreq>
145133
<priority>0.8</priority>
146134
</url>
147135
<url>
148136
<loc>https://techstackglobal.github.io/posts/budget-laptops-under-1000.html</loc>
149-
<lastmod>2026-03-05</lastmod>
137+
<lastmod>2026-03-07</lastmod>
150138
<changefreq>monthly</changefreq>
151139
<priority>0.8</priority>
152140
</url>
153141
<url>
154142
<loc>https://techstackglobal.github.io/posts/dell-thunderbolt-smart-dock-review.html</loc>
155-
<lastmod>2026-03-05</lastmod>
143+
<lastmod>2026-03-07</lastmod>
156144
<changefreq>monthly</changefreq>
157145
<priority>0.8</priority>
158146
</url>
159147
<url>
160148
<loc>https://techstackglobal.github.io/posts/dell-xps-15-9530-review.html</loc>
161-
<lastmod>2026-03-05</lastmod>
149+
<lastmod>2026-03-07</lastmod>
162150
<changefreq>monthly</changefreq>
163151
<priority>0.8</priority>
164152
</url>
165153
<url>
166154
<loc>https://techstackglobal.github.io/posts/do-you-need-thunderbolt-dock.html</loc>
167-
<lastmod>2026-03-05</lastmod>
155+
<lastmod>2026-03-07</lastmod>
168156
<changefreq>monthly</changefreq>
169157
<priority>0.8</priority>
170158
</url>
171159
<url>
172160
<loc>https://techstackglobal.github.io/posts/is-a-4k-monitor-worth-it.html</loc>
173-
<lastmod>2026-03-05</lastmod>
161+
<lastmod>2026-03-07</lastmod>
174162
<changefreq>monthly</changefreq>
175163
<priority>0.8</priority>
176164
</url>
177165
<url>
178166
<loc>https://techstackglobal.github.io/posts/is-samsung-990-pro-worth-it.html</loc>
179-
<lastmod>2026-03-05</lastmod>
167+
<lastmod>2026-03-07</lastmod>
180168
<changefreq>monthly</changefreq>
181169
<priority>0.8</priority>
182170
</url>
183171
<url>
184172
<loc>https://techstackglobal.github.io/posts/lg-27us500-w-ultrafine-monitor-review.html</loc>
185-
<lastmod>2026-03-05</lastmod>
173+
<lastmod>2026-03-07</lastmod>
186174
<changefreq>monthly</changefreq>
187175
<priority>0.8</priority>
188176
</url>
189177
<url>
190178
<loc>https://techstackglobal.github.io/posts/samsung-990-pro-ssd-review.html</loc>
191-
<lastmod>2026-03-05</lastmod>
179+
<lastmod>2026-03-07</lastmod>
192180
<changefreq>monthly</changefreq>
193181
<priority>0.8</priority>
194182
</url>
195183
<url>
196184
<loc>https://techstackglobal.github.io/posts/samsung-odyssey-g8-review.html</loc>
197-
<lastmod>2026-03-05</lastmod>
185+
<lastmod>2026-03-07</lastmod>
198186
<changefreq>monthly</changefreq>
199187
<priority>0.8</priority>
200188
</url>
201189
<url>
202190
<loc>https://techstackglobal.github.io/posts/samsung-odyssey-g8-vs-alienware-aw3423dwf.html</loc>
203-
<lastmod>2026-03-05</lastmod>
191+
<lastmod>2026-03-07</lastmod>
204192
<changefreq>monthly</changefreq>
205193
<priority>0.8</priority>
206194
</url>
207195
<url>
208196
<loc>https://techstackglobal.github.io/posts/shure-sm7b-review.html</loc>
209-
<lastmod>2026-03-05</lastmod>
197+
<lastmod>2026-03-07</lastmod>
210198
<changefreq>monthly</changefreq>
211199
<priority>0.8</priority>
212200
</url>
213201
<url>
214202
<loc>https://techstackglobal.github.io/posts/shure-sm7b-vs-sm7db.html</loc>
215-
<lastmod>2026-03-05</lastmod>
203+
<lastmod>2026-03-07</lastmod>
216204
<changefreq>monthly</changefreq>
217205
<priority>0.8</priority>
218206
</url>
219207
<url>
220208
<loc>https://techstackglobal.github.io/posts/shure-sm7db-review.html</loc>
221-
<lastmod>2026-03-05</lastmod>
209+
<lastmod>2026-03-07</lastmod>
222210
<changefreq>monthly</changefreq>
223211
<priority>0.8</priority>
224212
</url>
225213
<url>
226214
<loc>https://techstackglobal.github.io/posts/sony-wh-1000xm5-review.html</loc>
227-
<lastmod>2026-03-05</lastmod>
215+
<lastmod>2026-03-07</lastmod>
228216
<changefreq>monthly</changefreq>
229217
<priority>0.8</priority>
230218
</url>
231219
<url>
232220
<loc>https://techstackglobal.github.io/posts/sony-xm5-vs-bose-qc-ultra.html</loc>
233-
<lastmod>2026-03-05</lastmod>
221+
<lastmod>2026-03-07</lastmod>
234222
<changefreq>monthly</changefreq>
235223
<priority>0.8</priority>
236224
</url>
237225
<url>
238226
<loc>https://techstackglobal.github.io/posts/surface-laptop-studio-2-review.html</loc>
239-
<lastmod>2026-03-05</lastmod>
227+
<lastmod>2026-03-07</lastmod>
240228
<changefreq>monthly</changefreq>
241229
<priority>0.8</priority>
242230
</url>
231+
<url>
232+
<loc>https://techstackglobal.github.io/privacy-policy.html</loc>
233+
<lastmod>2026-03-07</lastmod>
234+
<changefreq>monthly</changefreq>
235+
<priority>0.6</priority>
236+
</url>
237+
<url>
238+
<loc>https://techstackglobal.github.io/smart-tools.html</loc>
239+
<lastmod>2026-03-07</lastmod>
240+
<changefreq>monthly</changefreq>
241+
<priority>0.6</priority>
242+
</url>
243+
<url>
244+
<loc>https://techstackglobal.github.io/terms-of-service.html</loc>
245+
<lastmod>2026-03-07</lastmod>
246+
<changefreq>monthly</changefreq>
247+
<priority>0.6</priority>
248+
</url>
243249
</urlset>

0 commit comments

Comments
 (0)