Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

seo - Get Google to show localised Wordpress site in search results

I run a Wordpress multi-site that has an Irish/EU, UK and US site all on the same domain:

  • pestleandmortar.com - Irish/EU
  • pestleandmortar.com/uk - UK only
  • pestleandmortar.com/us - US/Canada

Customers are redirected by a plugin call IQ Country Block depending on where their IP is located. The problem is that if a customer does a organic search in Google, sometimes the EU site will appear in their results in the US and they can follow it through. The plugin doesn't appear to like this and lets them in. If the same customer then refreshes the page, the plugin kicks in and redirects them.

How to do I get Google to display the correct site for the region, so say people in the US, when they search get the US site URL in their results.

Thanks.

question from:https://stackoverflow.com/questions/65901568/get-google-to-show-localised-wordpress-site-in-search-results

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are three methods to instruct Google as to what country or language audience a given page is intended for. All of these methods rely on the use of an attribute called "hreflang" combined with a language/country ISO code pair.

You can find detailed documentation for hreflang at the Google developers site.

Before I get into the methods, you should be aware of a couple limitations of these methods:

  • You can only target one language/country pair, so you will have to choose one country for your US/Canada version
  • Only countries and languages which are supported by ISO 3166-1 and ISO 639-1, respectively, can be used, which means you can't target the EU (as it's not a country)

HTML Tag Method

The first method is through the use of HTML <link> tags placed in the <head> element. Each tag must contain rel="alternate", hreflang, and href attributes.

Example:
<link rel="alternate" hreflang="en-ie" href="http://www.pestleandmortar.com"
<link rel="alternate" hreflang="en-gb" href="http://www.pestleandmortar.com/uk"
<link rel="alternate" hreflang="en-us" href="http://www.pestleandmortar.com/us"

These same three tags go in the <head> of all three of the example pages you listed.

Sitemap Method

The same attributes are required for this method, but they are instead included in a xml sitemap file that is associated with your site.

Example:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>http://www.pestleandmortar.com/</loc>
    <xhtml:link rel="alternate" hreflang="en-ie" href="http://www.pestleandmortar.com/" />
    <xhtml:link rel="alternate" hreflang="en-gb" href="http://www.pestleandmortar.com/uk" />
    <xhtml:link rel="alternate" hreflang="en-us" href="http://www.pestleandmortar.com/us" />
  </url>
  <url>
    <loc>http://www.pestleandmortar.com/uk</loc>
    <xhtml:link rel="alternate" hreflang="en-ie" href="http://www.pestleandmortar.com/" />
    <xhtml:link rel="alternate" hreflang="en-gb" href="http://www.pestleandmortar.com/uk" />
    <xhtml:link rel="alternate" hreflang="en-us" href="http://www.pestleandmortar.com/us" />
  </url>
  <url>
    <loc>http://www.pestleandmortar.com/us</loc>
    <xhtml:link rel="alternate" hreflang="en-ie" href="http://www.pestleandmortar.com/" />
    <xhtml:link rel="alternate" hreflang="en-gb" href="http://www.pestleandmortar.com/uk" />
    <xhtml:link rel="alternate" hreflang="en-us" href="http://www.pestleandmortar.com/us" />
  </url>
</urlset>

HTTP Header Method

Once again, the same attributes are provided, except these included in your site's http headers.

Example:

Link: <http://www.pestleandmortar.com/>; rel="alternate"; hreflang="en-ie",
      <http://www.pestleandmortar.com/us>; rel="alternate"; hreflang="en-us",
      <http://www.pestleandmortar.com/uk>; rel="alternate"; hreflang="en-gb"

Some Things to Keep in Mind

  • Hreflang works in "clusters" of related pages. Make sure that each of these clusters, such as the three pages you shared in your question, all reference each other. This will look like a lot of boilerplate - and it is - but without it, the "return loop" of these pages will be broken, and the pages may not appear in the correct search results.

  • Only use 200 status URLs that do not include a noindex directive or a canonical tag, as this will also break the relationship between the pages.

  • Consider choosing a version of your site to use as an x-default. This will instruct Google to display a default version of the site in cases where this is no suitable match. For example, a user in Cameroon can potentially still see the default version of the site in search results. broken, and Google won't be certain that the pages are related.

  • Other search engines don't use hreflang markup, such as Bing. If you want to make sure other search engines serve the correct version to their users, you'll need to set up your pages with appropriate <html lang=""> elements. The value in the lang attribute is the same as the language ISO codes I mention above. Note that there is no way to target a country with this particular method.

A Word About Geo-Blocking

You mention you are relying on a plugin that uses Geo-IP detection to block users from certain countries from seeing your content. There are a few reasons why you should not do this.

  • Reason 1: Google's crawlers are primarily US-based. If they can't crawl the content, they can't index and rank it. That's a bad thing.

  • Reason 2: What you are doing appears to constitute geo-blocking, which is illegal in the EU and carries a potential penalty of fines. That's also a bad thing. The fact that you're not discriminating between countries within the EU may mean you're in the clear, but I'm not a lawyer, so don't take that as legal advice.

  • Reason 3: Your potential customers may visit your site while abroad, which means they may have an IP addressed associated with a location you are blocking. You're potentially losing sales due to preventing them from accessing the site. This is very obviously a bad thing.

"Just tell me how to set it up in WordPress!"

Since your site is built with WordPress, there are some plugins you can try that may make the setup of hreflang easier.

I can only vouch for WPML, as I have never tried Polylang, but I thought I would include a free and open source alternative to WPML.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...