Preventing automatic modification to page slug its title is changed

267 views
Skip to first unread message

Brett Grace

unread,
Jan 6, 2015, 7:54:44 PM1/6/15
to wag...@googlegroups.com
Currently the slug field on the promote panel is wired to update itself when the title is changed on the content panel. This is creating some UX and SEO problems (I can elaborate if necessary, but the issue is with a page being indexed and or bookmarked, and the title being updated, so that bookmarks and search engines have a broken link).

I'm confident that I can code around this, probably by using a signal handler to intercept and revert changes to the slug, or by using the publishing hook to create a redirect.

Before I go down that route I'd like to ask, is this configurable through Wagtail or is there a more idiomatic approach I should be taking?

Thanks.

David Cranwell

unread,
Jan 7, 2015, 4:51:41 AM1/7/15
to wag...@googlegroups.com
If I understand you correctly I think this issue is most pertinent:


Its behaviour is definitely worth reconsidering but there are currently no plans to tackle this in the short-term. If you're interesting in patching/reworking how slugs are auto-generated we'd welcome your help as we've got quite a mountain of things to get through.

Dave

Brett Grace

unread,
Jan 7, 2015, 2:22:16 PM1/7/15
to wag...@googlegroups.com
Ah, yes, thanks, that's it, sorry I didn't research the issue tracker thoroughly. No worries about the backlog, just wanted to make sure I wasn't about to tackle a solved problem. I'll probably fix this for my own case initially, publish that, and then gauge the amount of effort required for the general case. 

Robert Rollins

unread,
Jan 8, 2015, 1:55:30 AM1/8/15
to wag...@googlegroups.com
I just implemented this exact feature in my wagtail site today. Here's how I did it:

Register a function for the 'insert_editor_js' hook, and have it include a script tag (linking to a file or having inline javascript). In that JS, execute:
$(function() { $('#id_title').off(); });

That will unhook the events which cause the slug to be updated. You can add some extra logic to make it only unhook on edit pages (letting the initial page save form auto-generate it), by looking for the word "Editing" in the <title> tag.

Brett Grace

unread,
Jan 8, 2015, 1:48:51 PM1/8/15
to wag...@googlegroups.com
Very cool, thanks!
Reply all
Reply to author
Forward
0 new messages