开发者

What's the advantage or benefit of Slug field in Django?

What's the benefit of the slug field? Does it make the url more searching engine fri开发者_如何转开发endly? If it does, how? Isn't a meaningful title of the page searching engine friendly enough?


The slug provides a human-friendly url fragment for the page. This is often useful when people are deciding whether or not to click a link. There's one in the url of this page, for example:

http://stackoverflow.com/questions/6192655/whats-the-advantage-or-benefit-of-slug-field-in-django

You can actually get to this question without the slug (in StackOverflow's system), but a slug is a more friendly and more semantic way to address the page. Search engines do place some weight on words that appear in the address of the page.

One downside of using only the slug to address a page is that if you change the content of the page and wish to change the title, you have to decide between changing the slug, or leaving it as is (and thus not reflecting the content of the page). StackOverflow's compromise of having the slug but not relying on it is one solution.

Nothing in Django requires you to use slugs in your application, but it's a convenience that's present because many of us do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜