Welcome to WebmasterWorld Guest from 34.204.189.171

Forum Moderators: open

How to write html page for 2 languages links?

     
12:52 pm on May 26, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


Hi so I have a html page where I'll place a few links with two languages.

Right now I have only English links and so I've placed <html lang="en"> currently. What should I add for the other language which is say, Spanish? Thanks!
3:35 pm on May 26, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4510
votes: 348


If you mean the meta tag that you have posted, it is not so much interested in all the languages of link targets so much as the actual language that is used on that actual page. Claiming multiple languages that are not present on the page itself will not be helpful to you or your visitors. You might try using anchor text to indicate the language of the target URL.
7:00 pm on May 26, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15874
votes: 872


What should I add for the other language which is say, Spanish?
<html lang = "es"> of course. No need to get more specific ("es-es" and so on) unless you're offering more than one version of the same language.

You can attach the "lang" attribute to almost any html tag, but it isn't normally worth it unless the content is clearly language-specific ("click here" vs. "whatever-the-verb-is aquí").
9:53 pm on May 26, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:10458
votes: 1091


Unless the page is bilingual, keep it simple. Meanwhile, having two language attributes will only confuse the search engines. YMMV
9:59 pm on May 26, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


Is there any harm if I don’t use the lang attribute? Just use <html>
10:16 pm on May 26, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:10458
votes: 1091


Personally never used lang ... the se's seem to know what they are looking at.
11:00 pm on May 26, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


I checked and so if I have say two languages in a page, US-English and Spanish the guidelines are to add these tags to the page:

<link rel="alternate" href="https://www.example.com" hreflang="en-us" />
<link rel="alternate" href="https://www.example.com" hreflang="es-us" />

Is this correct and is there anything else I need to do? Thanks!
11:20 pm on May 26, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


The thing is same page is bilingual. So that's the original question I had.
11:36 pm on May 26, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


I'm just using these tags:

<p><a hreflang="es" href="https://www.w3schools.com">W3Schools.com</a></p>
12:23 am on May 27, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4510
votes: 348


This type of language tags:
<link rel="alternate" href="https://www.example.com" hreflang="en-us" />
are not for your page with both languages. That tag is for alternative pages with one language or the other; that format is for alerting Google to the presence of substantially identical pages in another language. There's more at Google: [support.google.com...]

Since you have one page with both languages, you can use the simple tag:
<html lang="en, es" />

or no language at all, it is up to you. In your case no tag is required but you can use the simple tag if you want.

AFAIK, the "en-us" format is for use if you offer various "en" variations.

1:22 am on May 27, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15874
votes: 872


fwiw, Google ignores the "lang" attribute, no matter where it finds it. But human-oriented functions such as text-to-voice readers obviously need it.
<html lang = "en, es">
Gosh, not2easy. It never occurred to me it was legal (as it were) to do this. But what does the poor screen reader do?

Edit after flying visit to validator: w3 says nope, not legal. In fact, as I typed it in, they flagged it as two separate errors (one for the comma, one for the space). You can only name one language.
2:49 am on May 27, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4510
votes: 348


You're right lucy24, no idea where that came from, I can't find a reference. My bad.

It looks like your best bet is to omit any language tag at all and use the line where Google says they determine the language [support.google.com] from the content - under the heading "Make sure the page language is obvious":
Google uses the visible content of your page to determine its language. We don’t use any code-level language information such as lang attributes, or the URL. You can help Google determine the language correctly by using a single language for content and navigation on each page, and by avoiding side-by-side translations.
But that says you should have separate pages for each language. My guess is that if it is ONE page, it may not be a big deal. If it amounts to large chunks of the content, it would be more important.

2:54 am on May 27, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:10458
votes: 1091


Again, no language required.

If you have a page that offers the same info bilingual, just have paragraphs of those languages in use:

English stuff here

Spanish here

etc.

The search engines will find it and index it.

Don't over think this.

Note: all above applies only to pages that have both languages.

Otherwise HAVE TWO FREAKIN' PAGES and mark each as suitable...

Yet, one more time, I have never used the lang tag for all the obvious reasons, most prominent of which is the language in which the page is written should be the chief giveaway. :)
3:06 am on May 27, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


Hmm not even this format for links?

<p><a hreflang="es" href="https://www.w3schools.com">W3Schools.com</a></p>
4:24 am on May 27, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15874
votes: 872


not even this format
Yes, yes, you can do that [w3.org] (or rather, you can still do it in HTML 5 [w3.org]) if you like--though the linking text should already make it obvious (“page in English”, “pagina-or-whatever-the-word-is en español”).

This is the html subforum, not google/seo. What is your underlying purpose? What are you trying to accomplish? Whom do you want to benefit? What information do you need to convey, and why?
6:10 am on May 27, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:10458
votes: 1091


The text on page (what is indexed) is the determination.

KISS this and go from there.
11:10 am on May 27, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Dec 19, 2004
posts:993
votes: 14


Ok thanks, I just wanted the technically correct guidelines. Thanks again!
1:37 pm on May 27, 2019 (gmt 0)

Preferred Member from CA 

Top Contributors Of The Month

joined:Feb 7, 2017
posts:575
votes: 59


I do bilingual content all the time, left side English, right side Chinese. I don't do anything special with metatags. Google picks it up just fine. The Chinese search engines don't pick up my Chinese content, but maybe they don't like my independent political views.