Pastor | 22 апреля 2022 г. 15:32
Fixed very stupid flaw with the Django Sitemap.
I`m using standard Django sitemap framework django.contrib.sitemaps.views that generates sitemap.xml with the following URL :
<urlset xmlns="http: www.sitemaps.org="" schemas="" sitemap="" 0.9"="">
<url>
<loc>https://what2brew.com/blog/redesign_completed/</loc>
<lastmod>2022-04-21</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
The problem here is the missing WWW prefix in the URL since I have enabled HTTPS and WWW on my provider settings. If I manually navigate to the generated URL, I get a 404 error.
Spent some time looking at the Django docs and Stack Overflow. To fix this error, you don`t need to code at all.
Just visit Django Admin panel -> Sites -> Domain Name. If your site looks like mysite.com, just change it to www.mysite.com and save your changes. You can also change the Display name, but this is not required.
Now I have a fixed URL
<urlset xmlns="http: www.sitemaps.org="" schemas="" sitemap="" 0.9"="">
<url>
<loc>https://www.what2brew.com/blog/redesign_completed/</loc>
<lastmod>2022-04-21</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
Have a nice day!
Обсуждение еще не началось, но Вы можете направить запрос в Телеграм@W2Brew