DigtheDirt has to be an SEO beast. Has to be. But I don’t like permalinks or slugs. At least, I don’t like them in Rails.
Most blogging software treats the permalink like a necessary evil, but the truth is that you can get pretty close to SEO nirvana by overriding to_param in your model, a trick posted by Obie Fernandez.
def to_param “#{id}-#{title.gsub(’ ‘, ’-’}” endThe problem with that approach is that you can get burned in SEO if the title in your model changes. You’d have multiple URLs pointing to identical content. And that’s bad. I found this problem with webmaster tools after finding a massive duplication problem.
At DigtheDirt, I just redirect if the incoming title does not match the title in the model. Problem solved. It’s not perfect, because the id on the front end of the model is a little bit ugly. I can live with that because everything else is completely automatic.
I think I have to live with the redirect because the title is one of the best pieces of a page to optimize, and I don’t want to lose that flexibility.
So all in all, I’m happy with the compromise.