[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: New language selector: Validation failed - attribute "hreflang" in "option"



Hi Laura, 

Thank you for highlighting the validation errors regarding the hreflang attribute in the <option> tags. I appreciate your guidance on this.

You're correct that the hreflang attribute is not valid for <option> elements; it should only be used with href attributes in <link> or <a> tags. I've removed it from the <option> elements in the updated code.

For context, the hreflang attribute is beneficial for SEO as it helps search engines identify the appropriate language and regional version of a page. However, since we are utilizing content negotiation in the Apache configuration, omitting hreflang should not pose an issue. The server will automatically serve the correct language based on user settings.

You can review the changes in my merge request here: Merge Request #1012.

For further reference, here's a link to the MDN documentation on hreflang: MDN web Docs - hreflang 

Best regards

Divine Attah



On Wed, Oct 30, 2024 at 6:46 PM Laura Arjona Reina <larjona@debian.org> wrote:
Hello

Thanks Divine Attah and all the prior and post work, we have a new
language selector in the footer in www.debian.org, that closed the bug
#924889 with MR 1004.

However, I have noticed HTML validation errors, related to the attribute
hreflang used in the different "options" of the language selector.

For example for Spanish I'm getting these warnings:

*** Errors validating /srv/www.debian.org/www/mirror/index.es.html: ***
Line 100, character 55: there is no attribute "HREFLANG"

First I thought that maybe "hreflang" is an HTML5 attribute and we could
ignore it for now (see bug #1009971), but I tried to build
webwml/english/mirror/index.wml changing the reference to "template" to
"template5" (see bug #980921), and the page built fine, uploaded it to
https://cosas.larjona.net/debian/index.en.html and the HTML5 online
validator available here https://html5.validator.nu/ still outputs
warnings like:

Attribute hreflang not allowed on element option at this point.
 From line 96, column 2; to line 96, column 70
/option>↩ <option value="index.da.html" title="Danish" hreflang="da"
lang="da">dansk<

So I believe that there is an issue and probably hreflang cannot be used
in "option" items.

My HTML/HTML5 skills are not enough, can somebody help?

(OTOH I don't know why I'm not getting validation errors for all the
pages, and only the mirror/index page. In
https://www-master.debian.org/build-logs/validate/en I have seen similar
warnings in other pages, but not all the pages that use the footer
either. Maybe our validation script does not try check all the files).

Links of bugs and MR mentioned:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=924889 -  Use a drop
down selector (without JS) to switch the language of the website

https://salsa.debian.org/webmaster-team/webwml/-/merge_requests/1004 -
Fix bug 924889 readjustment

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009971 -
Our current validation script does not work with html5 files

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980921 -
Pages in HTML5

Kind regards

Laura Arjona Reina


Reply to: