1

I have the scenario where two links should redirect to the same page, similar to the case of Wikipedia where https://en.wikipedia.org/wiki/Main_Page and https://en.wikipedia.org/wiki/ both point to the same page.

I am using the Django framework. To implement that in Django I can have two different URL patterns in urls.py, each pattern pointing to the same page.

path('wiki/', views.main_page),
path('wiki/main_page', views.main_page)

However, this Google Search Central article about duplicate content seem to note that the above idea isn't' a good idea:

Be consistent: Try to keep your internal linking consistent. For example, don't link to http://www.example.com/page/ and http://www.example.com/page and http://www.example.com/page/index.htm.

And they seem to advocate the use of 301 redirects:

Use 301s: If you've restructured your site, use 301 redirects ("RedirectPermanent") in your .htaccess file to smartly redirect users, Googlebot, and other spiders. (In Apache, you can do this with an .htaccess file; in IIS, you can do this through the administrative console.)

Does that mean I'd better set 301 redirects using the Django redirect app instead of creating multiple URL patterns?

2 Answers 2

1

It sounds like you have option of just using a single URL. Do you need the path('wiki/main_page', views.main_page) configuration? It sounds like you could just omit that. If you only use the simple wiki/ URL, you don't have to worry about duplicate content or redirects.

On most systems the duplication is caused by the directory URL being powered by a file with some default name. The default behavior of many web servers is to have both the directory URL and the directory URL with the default name appended serve the same file. You usually have to add special configuration to override the behavior of showing the file for the longer URL.

You have many options:

  1. Best: Redirect /wiki/main_page to /wiki. Make sure no links on your site point to /wiki/main_page.
  2. Great: Don't create the /wiki/main_page URL. (Assuming you have never used /wiki/main_page in the past and you don't currently link to it.)
  3. Good: Create both URLs, and use canonical meta tags to tell search engines which you prefer
  4. Good: Create both URLs and use canonical HTTP headers to tell search engines which you prefer
  5. OK: Create both URLs and only include one of the two (wiki/) in your XML sitemap which tells search engines that you prefer that one.
  6. OK: Create both URLs and keep the longer one secret. Never link to it, reference it, or include it in a sitemap. (Assuming you have never used it and don't currently link to it. If you ever linked to it, the secret is already out of the bag.)
  7. Not recommended: Use both URLs and let search engines figure things out on their own. Google is a lot better about this than it used to be. It will usually choose to index one of the two URLs. It tends to have a preference for shorter URLs and URLs that are linked more often.

Google has a guide about consolidating duplicate URLs that walks through the pros and cons of several of these methods and shows to to implement each of them: https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls

1

It's better to use redirects. Multiple URLs with the same content is bad, as described in the link you mentioned.

Actually, you can use the canonical header or meta tag, but it has many cons. And Google says:

Use 301 redirects to tell Googlebot that a redirected URL is a better version than a given URL. Use this only when deprecating a duplicate page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.