简体   繁体   中英

Make slug mandatory in page URL?

I'm deciding whether or not to make the slug mandatory in order to view a submission.

Right now either of these works to get to a submission:

domain.com/category/id/1/slug-title-here

domain.com/category/id/1/slug-blah-foo-bar

domain.com/category/id/1/

All go to the same submission.

You can also change the slug to whatever you want and it'll still work as it just checks for the category, id, and submission # (in the second example).

I'm wondering if this is the proper way to do this? From an SEO standpoint should I be doing it like this? And if not, what should I be doing to users who request the URL without the slug?

The slug in the url can serve three purposes:

  1. It can act as a content key when there is no id (you have an id,so this one doesn't apply)
  2. When just a url is posted as a link to your site, it can let users know what content to expect because they see it in the url
  3. It can be used by search engines as a ranking signal (Google does not use url words as a ranking signal very much right now as far as I can tell)

Slugs can create problems:

  1. Urls are longer, harder to type, harder to remember, and often get truncated
  2. It can lead to multiple urls for the same page and SEO problems with content duplication

I am personally not a fan of using a slug unless it can be made the content key because of the additional issues it creates. That being said, there are several ways to handle the duplicate content problems.

Do nothing and let search engines sort out duplicate content

They seem to be doing better at this all the time, but I wouldn't recommend it.

Use the canonical tag

When a user visits any of the urls for the content, they should get a canonical tag like such:

<link rel="canonical" href="http://domain.com/category/id/1/slug-title-here" />

As far as Google is concerned, the canonical tag can even exist on the canonical url itself, pointing to itself. Bing has advised against self referential canonical tags though. For more information on canonical tags see: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

Use 301 redirects

Before canonical tags, the only way to avoid duplicate content would be with 301 redirects. Your software can examine the url path, and compare the slug to the correct slug. If they don't match, it can issue a 301 redirect that will send the user to the canonical url with the correct slug. The stack overflow software works this way.

so these urls:

domain.com/category/id/1/slug-blah-foo-bar
domain.com/category/id/1/

would redirect to

domain.com/category/id/1/slug-title-here

which would be the only url that would actually have the content.

Assuming you're not ever going to change a page's slug, I'd just set up domain.com/category/id/1/ to do a 301 redirect (permanent) to domain.com/category/id/1/slug-title-here , and any time someone enters a slug which is incorrect for that article ( domain.com/category/id/1/slug-title-here-oops-this-is-wrong ), also 301 them to the correct address.

That way you're saying to the search engines "I don't have duplicate content, look, this is a permanent redirect" so it doesn't harm your SEO, and you're being useful to the user in always taking them to the correct "friendly url" page.

I suggest you to make a rel=canonical meta tag.

This prevents do a redirect each time considering someone can link your page with infinte variant like this:

domain.com/category/id/1/?fakeparam=1

From a SEO standpoint, as long as your only ever linking to one version of those URL's, it should be fine as the other URL's won't even be picked up by the search engine (as nowhere links to them).

If however you are linking to all 3, then it could hurt your rankings (as it'll be considered duplicate content).

I personally wouldn't make the slug required, but I would make sure that (internally) all links would point to a URL including the slug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM