Managing sitemaps for the website
A website's sitemaps are crucial for any website. The search engine will use website sitemaps to index the pages of a website. In this recipe, we will add book details pages to the sitemap.
Getting ready...
For this recipe, we will be using the my_library
module from the previous recipe. If you want to check the current sitemap in Odoo, open <your_odoo_server_url>/sitemap.xml
in your browser. This will not have the book's URL in it.
How to do it...
Follow these steps to add a book's page to sitemap.xml
:
- Import the methods in
main.py
, as follows:from odoo.addons.http_routing.models.ir_http import slug from odoo.addons.website.models.ir_http import sitemap_qs2dom
- Add the
sitemap_books
method tomain.py
, as follows:class Main(http.Controller): ... Â Â Â Â def sitemap_books(env, rule, qs): Â Â Â Â Â Â Â Â Books = env['library.book'] Â Â Â ...