how to suppress previews for links in HTML `content`/`summary`?

Open
#650 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
html
Domain
documentation

Research direction

No implementation file or test is identified. Start by reviewing the Activity Streams 2.0 specification and the linked Mastodon and Trust & Safety issues, then compare the proposed rel="nopreview" and attachment-based approaches. Done would require a decided, interoperable way for federating services to suppress previews, with its scope and semantics documented.

Written by the indexing model from the issue text.

Description

needs-fep

Originally filed as https://github.com/mastodon/mastodon/issues/35717.

When user-facing ActivityStreams services render objects with HTML content, they often generate a link preview for links (<a> tags) in it. That's great! ...except for when they're not wanted. Some links are sensitive, or not informationally useful, or won't have good preview metadata. It'd be nice for services that create and federate objects to be able to specify which content links shouldn't get a preview. Maybe with rel=nopreview, which doesn't exist yet, or a similar class?

Evidently rel=tag, class=u-url, class=h-card currently have this effect in some fediverse implementations. They're not ideal, since they carry semantics, and they're not officially supported for this use, but it's a start.

From https://discord.com/channels/231908446830723072/734716731150303242 :

A: One idea was that it should be based on if there's a Link object attached or not, but by the sounds of it, Mastodon will generate a link preview from just the content?
A: Another idea was maybe rel="nopreview" but that's not currently a thing within HTML
B: lol rel=nopreview is one thing I was thinking. great minds, etc
B: could also (re)use rel=nofollow 🤷‍♂️
B: yeah Mastodon generates previews from tags in content alone
A: Oh, interesting, looks like it doesn't even pay attention to the Link attachments
A: as a hack you could mark the links with class="u-url"
C: Twitter used to generate previews based on the last URL in the body of the text (and save those as cards in the backend). A Tweet could only have one type of attachment though, so if an image was also included in the post, it would override the link preview. I mention this because Mastodon had similar behaviours to Twitter at the beginning - I have not look at what the current implementation does.
C: that's not a way to suppress a link preview in a text-only post, regardless.
D: Some accounts do exactly that to avoid the thundering herd problem of thousands of servers all connecting at once to generate the preview.
B: should I file an issue? there are a few existing issues, but afaict all of them are for Mastodon users or admins, not for external services federating into Mastodon
E: rel=tag or class=u-url or class=h-card will currently skip link preview generation but none of these are specifically designed to suppress them, if rel=nopreview is a real thing I'd be happy to add support for it

https://github.com/swicg/activitypub-trust-and-safety/issues/97 is related, as are https://github.com/mastodon/mastodon/issues/20188, https://github.com/mastodon/mastodon/issues/23612, https://github.com/mastodon/mastodon/issues/24015, https://github.com/mastodon/mastodon/issues/30802.

Dominant language
HTML
Stars
313
Forks
70
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from w3c/activitystreams

All issues in w3c/activitystreams

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.