Canonical slug detail mixin, with docs and passing tests. #61

Merged
merged 5 commits into from Aug 2, 2013

Projects

None yet

3 participants

@folz
Contributor
folz commented Jul 30, 2013

This pull request adds a mixin that enforces a canonical slug in the url, while still using the pk for object lookup. If the url slug argument isn't equal to the canonical slug, the mixin redirects to the canonical slug. Otherwise, the page load continues as normal.

Benefits: prevent duplicate content SEO penalty if a non-canonical link is somehow indexed by a search engine.

Example (also in the docs):

Article: {pk: 1, slug: 'hello-world'}

>>> HEAD http://127.0.0.1:8000/article/1-hello-world
HTTP/1.1 200 OK

>>> HEAD http://127.0.0.1:8000/article/1-goodnight-moon
HTTP/1.1 301 Moved Permanently
Location: http://127.0.0.1:8000/article/1-hello-world

I've tried to document and test this mixin in the style of the existing mixins. Let me know if this PR is acceptable or if I should make additional changes.

@chrisjones-brack3t
Member

Will look into this Friday. Thanks.

@kennethlove kennethlove merged commit 743b802 into brack3t:master Aug 2, 2013
@folz
Contributor
folz commented Aug 2, 2013

Thanks for looking at this, and glad it was useful!

@folz folz deleted the unknown repository branch Aug 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment