Named Alternates for WordPress


HTML documents have the concept of an alternate representation of the document.

For example, a page's header might say:

<link rel="alternate" type="application/rss+xml" href="https://shkspr.mobi/blog/feed">

That tells you there's an alternative representation of the page, what sort of content it is, and where it is located. That's nice. But it's hard for a browser to tell the user what that page is. It might be able to guess from the type, but it isn't always certain.

So the <link> element can have a title attribute:

HTML HTML<link  rel="alternate" 
     title="Read my RSS feed!"
      type="application/rss+xml"
      href="https://shkspr.mobi/blog/feed">

Brilliant! Now your browser can explicitly tell you what the alternatives are. Here's what my WordPress blog looks like in Lynx (the text only browser).

Screenshot of Lynx showing a list of links named things like Atom Feed and RSS Feed.

But there's a small problem with WordPress. Individual pages have this alternative representations:

HTML HTML<link rel="alternate" type="application/json" href="https://shkspr.mobi/blog/wp-json/wp/v2/posts/50738" /
<link rel="alternate" type="application/json+oembed" href="https://shkspr.mobi/blog/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fshkspr.mobi%2Fblog%2F2024%2F06%2Femf-2024-a-quick-retrospective%2F" />
<link rel="alternate" type="text/xml+oembed" href="https://shkspr.mobi/blog/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fshkspr.mobi%2Fblog%2F2024%2F06%2Femf-2024-a-quick-retrospective%2F&format=xml" />

Because they don't have title attributes, this is how Lynx renders the links:

Screenshot of Lynx showing a list of links which just say "alternate".

I was a bit annoyed with this so, rather than letting my frustrations eat away at my soul until I became a bitter and withered husk of a man, I raised the issue with WordPress. It is a fairly simple change - although it does have some translation and localisation implications.

And, I am delighted to say, the suggestion was accepted and is now be available in WordPress 6.6!

Here's what WordPress sites look like now:

Screenshot of Lynx, the text browser, showing named alternates.

Showing that there are alternate representations in JSON, as well as oEmbed in JSON and XML. Nice!

Remember - the web is what you make it. You have the power to change its direction for the better.


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

One thought on “Named Alternates for WordPress”

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">