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

merged 5 commits into from Aug 2, 2013


None yet

3 participants

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/1.1 200 OK

>>> HEAD
HTTP/1.1 301 Moved Permanently

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.


Will look into this Friday. Thanks.

@kennethlove kennethlove merged commit 743b802 into brack3t:master Aug 2, 2013
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