Thursday, April 17, 2025
HomeBlogChanging Blog URLs in Odoo A Complete Guide

Changing Blog URLs in Odoo A Complete Guide

Introduction

Odoo is a powerful open-source ERP system that includes a built-in website and blog module. By default, Odoo generates URLs for blog posts dynamically based on the blog title and ID. However, you may want to customize these URLs for better SEO, readability, and branding.

In this guide, we will walk you through the process of changing the blog URL blog/rr-events-4/rr-events-42 to a more user-friendly format in Odoo.

Understanding Odoo Blog URL Structure

Odoo automatically generates blog post URLs based on the following structure:

/blog/<blog-name-ID>/<post-title-ID>

For example, the URL blog/rr-events-4/rr-events-42 is structured as follows:

  • blog/ – Identifies that it is a blog post.
  • rr-events-4 – Represents the blog name along with its ID (4).
  • rr-events-42 – Represents the specific post title along with its ID (42).

Methods to Change the Blog URL in Odoo

1. Editing the Slug in Odoo Backend

Odoo allows manual customization of the slug (the part of the URL that comes after the domain name) directly in the backend.

Steps:

  1. Navigate to Website > Blog in your Odoo backend.
  2. Click on the specific blog post you want to edit.
  3. Locate the SEO & URL section.
  4. Modify the Slug field to your desired format (e.g., new-event-title).
  5. Save the changes and check if the URL has been updated.

2. Using Odoo’s Website Editor

Odoo provides an intuitive website editor that allows you to edit URLs directly from the front end.

Steps:

  1. Go to your Odoo website and navigate to the blog post.
  2. Click the Edit button on the top right.
  3. Select the SEO & URL option.
  4. Change the Slug to a more meaningful name.
  5. Save your changes and reload the page.

3. Modifying the Blog Controller (Advanced Users)

If you need a more automated way to control URL structure, you may modify the blog controller in Odoo.

Steps:

  1. Open your Odoo custom module or create a new one.
  2. Locate the website_blog module.
  3. Extend the WebsiteBlog controller in Python:from odoo.addons.website_blog.controllers.main import WebsiteBlog from odoo import http class CustomBlogController(WebsiteBlog): @http.route(['/blog/<string:blog_slug>/<string:post_slug>'], type='http', auth='public', website=True) def blog_post(self, blog_slug, post_slug, **kwargs): post = request.env['blog.post'].search([('slug', '=', post_slug)], limit=1) if post: return http.request.render('website_blog.blog_post_complete', {'blog_post': post}) return http.request.not_found()
  4. Restart Odoo and update your module.
  5. Test the new URL structure.

4. Using URL Rewriting in Nginx or Apache (Server Level)

If you are running Odoo on a dedicated server, you can use Nginx or Apache to rewrite URLs.

Nginx Configuration:

location /blog/ {
    rewrite ^/blog/rr-events-4/rr-events-42$ /blog/new-event-title permanent;
}

Apache Configuration:

RewriteEngine On
RewriteRule ^blog/rr-events-4/rr-events-42$ /blog/new-event-title [R=301,L]

5. Updating URLs in the Database (Caution: Advanced Users Only)

You can directly update the database entries to change blog URLs.

Steps:

  1. Open Odoo database using pgAdmin or a database management tool.
  2. Run the following SQL query:UPDATE blog_post SET slug = 'new-event-title' WHERE id = 42;
  3. Restart Odoo and clear the cache.
  4. Check the updated URL.

Best Practices for SEO-Friendly URLs

When updating blog URLs, follow these best practices:

  • Use descriptive keywords related to the content.
  • Keep the URL short and easy to read.
  • Use hyphens (-) instead of underscores (_) for better SEO.
  • Avoid special characters and numbers in URLs.
  • Implement 301 redirects for old URLs to prevent broken links.

Conclusion

Changing a blog URL in Odoo can significantly enhance user experience and SEO rankings. Whether you choose to edit URLs through the Odoo backend, modify the controller, or use URL rewriting, ensure that you follow best practices for a seamless transition.

By implementing the methods discussed above, you can effectively customize your Odoo blog URLs to be more meaningful and brand-friendly.

Read More…

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular