Using Canonical for Duplicate Content with friendly urls

199 views Asked by At

I have a rails app and in the app we are using 2 locale variables, :en & :fr

In the help section we have articles written in both language as;

...en/help/articles/5-booking-process #Content EN
...fr/help/articles/5-Processus-de-reservation #Content FR

But it creates also this;

...en/help/articles/5-booking-process

and the content is english. BUT, because of friendly id it also generates this url;

...en/help/articles/5-Processus-de-reservation

In this link, as @locale returns :en the content is english but the url - friendly part - is french.

I do not know how to avoid such a problem, should I add canonical or change the structure of routes.rb?

In routes.rb

Rails.application.routes.draw do

  scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do  
    ...
    ...
    ...
  end
end

PS: This is how I use friendly url in the relevant model:

def to_param
  "#{id}-#{title.parameterize}"
end
0

There are 0 answers