Django Google News Sitemap

346 Views Asked by At

Does anyone know how to implement the Google news sitemap standard on Django? https://developers.google.com/search/docs/advanced/sitemaps/news-sitemap

I am struggling to find any mention of how its implemented with Django.

Example of how it should look.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
  <url>
   <loc>http://www.example.org/business/article55.html</loc>
   <news:news>
   <news:publication>
     <news:name>The Example Times</news:name>
     <news:language>en</news:language>
   </news:publication>
   <news:publication_date>2008-12-23</news:publication_date>
     <news:title>Companies A, B in Merger Talks</news:title>
    </news:news>
  </url>
</urlset>

What I currently have looks very simple.

<url>
<loc>https://example.net/news/this-news-article/</loc>
<lastmod>2022-04-04</lastmod>
</url>
<url>
1

There are 1 best solutions below

0
Gonçalo Peres On

As of now the question is quite general, as one doesn't have access to the code OP is using.

So, taking that, the goal is to learn how to do it. For that there are at least two GitHub projects that I could find which implement a similar logic. In other words, they can be used to infer how to do it; there's a combination between urls.py, templates, ... in order to reach the desired goal... which isn't super straightforward to put it into an answer.

Here one can find the links to the projects

If one is looking for tutorials, these that DavidW shared might be useful: