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
<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).
But there's a small problem with WordPress. Individual pages have this alternative representations:
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:
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:
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.
One thought on “Named Alternates for WordPress”
@Edent There's an alternate universe where you do become a bitter and withered husk of a man
| Reply to original comment on mastodon.social
More comments on Mastodon.