Skip to content

Heads up on the failing tests check. I looked into it and I don't think it's something this PR can fix on its own, so here's what I found in case it's useful. #2013

Description

@go5515

Heads up on the failing tests check. I looked into it and I don't think it's something this PR can fix on its own, so here's what I found in case it's useful.

All 27 failures are broken-link errors of the form /<lang>/accessibility-best-practices-for-your-project/ ... which does not exist.

The source is the hreflang loop in _includes/head.html:

{% if page.lang and page.untranslated != true and site.data.locales.size > 1 %}
...
<link rel="alternate" hreflang="{{ lang }}" href="{{ site.url }}/{{ lang }}{{ default_url }}" />

The loop emits an alternate for every locale in _data/locales without checking whether that translation exists. It has never surfaced before because every locale folder in _articles/ currently carries an identical set of 12 articles. The only exception is accessibility-best-practices-for-your-project.md, which is English-only and shielded by untranslated: true.

This PR adds the first non-English copy of that article, so the block runs for it for the first time: 29 locales, minus en (handled separately and pointing at a page that does exist), minus ta itself, equals exactly the 27 errors reported.

That means any PR translating a new article into one language first will hit this, not just this one.

The natural fix is an existence guard on the non-en branch, reusing the pattern already in _layouts/article.html:

{% assign translated = site.articles | where: 'lang', lang | where: 'class', page.class | first %}
{% if translated %}...{% endif %}

I stopped short of putting that in this PR for two reasons. It's site build logic rather than translation work, and page.class is empty on localized non-article pages, so a naive guard would silently drop hreflang tags that those pages emit correctly today. That tradeoff felt like a maintainer's call rather than mine to make inside a translation PR.

Happy to open a separate PR for the guard, or fold it into this one if you'd prefer to keep them together. Just let me know which you'd rather have.

Publicado originalmente por @ajaitech en github/opensource.guide#3724 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions