Make WordPress Core

Opened 8 years ago

Last modified 8 years ago

#40587 new enhancement

Feed link markup should contain rel and type attributes

Reported by: henrywright's profile henry.wright Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Feeds Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The markup of feed links should really contain a rel and a type attribute. For example:

<a rel="alternate" type="application/rss+xml" href="https://example.com/feed">#</a>

The post_comments_feed_link() is an example of where this doesn't happen.

Attachments (3)

40587.diff (1016 bytes) - added by henry.wright 8 years ago.
40587.2.diff (1000 bytes) - added by stevenkword 8 years ago.
40587.3.diff (3.3 KB) - added by stevenkword 8 years ago.
Adding unit tests for confidence

Download all attachments as: .zip

Change History (19)

#1 in reply to: ↑ description ; follow-up: @subrataemfluence
8 years ago

Out of curiosity:

What additional benefit we would have by adding those two attributes? Also I presume you are actually looking for adding dynamic stuff to them rather than just use static values like "alternate" and "application/rss+xml". If yes, how you want this to work?

Replying to henry.wright:

The markup of feed links should really contain a rel and a type attribute. For example:

<a rel="alternate" type="application/rss+xml" href="https://example.com/feed">#</a>

The post_comments_feed_link() is an example of where this doesn't happen.

#2 follow-up: @henry.wright
8 years ago

Providing a rel attribute will indicate the relationship between the two documents. The type attribute allows us to specify the MIME type and is used as a hint to the user agent (usually the browser).

Also I presume you are actually looking for adding dynamic stuff to them rather than just use static values

Not in this case. The values will be static.

@henry.wright
8 years ago

#3 @henry.wright
8 years ago

I did some digging and as far as I can tell the only 2 functions that output feed link HTML are:

  • the_feed_link()
  • post_comments_feed_link()

40587.diff adds both a rel and type attribute to each.

#4 @henry.wright
8 years ago

  • Keywords has-patch added

@stevenkword
8 years ago

#5 in reply to: ↑ 2 @stevenkword
8 years ago

I like this idea but agree with @subrataemfluence in that it should detect type. I've updated a patch, 40587.2.diff which uses feed_content_type() instead of hard-coding the content-type.

Mozilla has a good article on implementation for this here:
https://developer.mozilla.org/en-US/docs/Web/RSS/Getting_Started/Syndicating

#6 @stevenkword
8 years ago

  • Milestone changed from Awaiting Review to 4.8

#7 @henry.wright
8 years ago

@stevenkword Nice use of feed_content_type() to account for all feed types. 40587.2.diff is a definite improvement.

#8 @subrataemfluence
8 years ago

@stevenkword feed_content_type() really adds flavor to this!

#9 @henry.wright
8 years ago

@subrataemfluence I understand now what you mean by "dynamic". Good suggestion!

@stevenkword
8 years ago

Adding unit tests for confidence

#10 @stevenkword
8 years ago

  • Keywords has-unit-tests added

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


8 years ago

This ticket was mentioned in Slack in #core by stevenkword. View the logs.


8 years ago

#13 in reply to: ↑ 1 @stevenkword
8 years ago

Replying to subrataemfluence:

Out of curiosity:

What additional benefit we would have by adding those two attributes?

Adding "rel" and "type" attributes to anchor tags and link tags facilitate feed auto-discovery. While the "link" tag found in the header is used to advertise the feed related to the rendered page, adding additional links containing these attributes allows the page to advertise additional feeds to search engines.

For example, a home page will contain a "link" element in the "head" that has a one-to-one relationship with main feed. However, an individual post from that same home page could advertise comment feeds for each individual post found on the page if these attributes were leveraged.

In another example, a widget could contain a link to a custom feed that would not otherwise be discovered without a sitemap.

See for more information: https://www.w3.org/TR/html5/links.html#rel-alternate

This ticket was mentioned in Slack in #core by stevenkword. View the logs.


8 years ago

This ticket was mentioned in Slack in #core by obenland. View the logs.


8 years ago

#16 @obenland
8 years ago

  • Milestone changed from 4.8 to Future Release
Note: See TracTickets for help on using tickets.