1

I apologise for the blatant ignorance of this question but I've been charged with fixing something in Django that I have NO experience with!

We're getting an issue with URLs and duplicated content.

If we visit "www.hello.com/services/" then we get our full page rendered, absolutely fine.

If we visit "www.hello.com/services" then we get the same content but with a default that seems to be set in a line:

class PageTitleNode(template.Node):?
 ?
    def render(self, context):?
        try:?
            meta_info = MetaInfo.objects.get(url=context['request'].path)?
        except ObjectDoesNotExist:?
            return u'This is our default page title'?
        return u"%s - hello.com" % meta_info.title

The main problem with this is that Google is indexing two almost identical pages and it's bad SEO according to our client's overpaid online strategy partner.

I know it's vague but if anyone can help then much rejoicing will be had.

Thanks for reading!

jpic
  • 32,891
  • 5
  • 112
  • 113
Cordial
  • 539
  • 3
  • 7
  • 22

1 Answers1

3

I think your consultant is correct. One URL = one resource. Having two urls on one resource is quite dirty anyway. This is why Django features automatic redirect from non trailing slash to urls with trailing slashes. Under certain conditions.

I'm pretty sure your url definition regexp for /services/ lacks the trailing slash. Anyway, you should use trailing slashes only:

  1. Ensure APPEND_SLASH is set to True: from django.conf import settings; print settings.APPEND_SLASH

  2. Ensure that all your url regexps have the trailing slash, e.g. url(r'foo' ...) is bad, and url(r'foo/' ...) passes barely because of possible conflicts and url(r'foo/$' ...) is better

  3. Ensure all MetaInfo objects have url with trailing slash, e.g. MetaInfo.objects.exclude(url__endswith='/') should return MetaInfo without trailing slash in url

jpic
  • 32,891
  • 5
  • 112
  • 113
  • Many thanks for your advice on this - it's not something I'm able to implement myself but I've passed it to someone with a little more confidence than me! – Cordial Mar 08 '12 at 10:15
  • I'm glad I could help - you should forward the above advice to the person you passed it too just in case it could help her/him. Please [close the question](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). – jpic Mar 08 '12 at 10:20