Discourse
← Discourse

How we link to sources

Discourse cites an article by its link, and one link is one Article. So a link is written in one spelling before it is stored, by the rules below. Nothing is fetched to decide it, and no redirect is followed.

The normal form

  1. The scheme must be https. The scheme and the host are written in lower case, and a default (443) or empty port is dropped.
  2. A fragment (everything from a # on) is dropped, with one exception: a hash-bang fragment, #! followed by at least one character, is kept, because some sites use it to choose the page. A bare #! is dropped.
  3. Characters outside ASCII are written as upper-case UTF-8 percent-escapes.
  4. A percent-escape of a letter, digit, hyphen, dot, underscore or tilde is decoded to the character; any other escape keeps its escape, in upper-case hex. An escaped slash (%2F) is never decoded.
  5. Then the dot segments of the path (/./ and /../) are removed, after the decoding, so an escaped /%2E%2E/ is removed too.
  6. An empty path becomes /.
  7. Tracking parameters are removed from the query (the list below), and so are empty parameters, left by a doubled, leading or trailing &. The others keep their order and spelling. A query left empty is dropped, with its ?.
  8. Inside a kept hash-bang fragment only the escapes are written in the one spelling; the rest is kept exactly as given.

Examples

RuleA link as givenAs stored
The scheme and host in lower case, the default port droppedHTTPS://Example.COM:443/Reporthttps://example.com/Report
A fragment droppedhttps://example.com/a#commentshttps://example.com/a
A hash-bang fragment kepthttps://example.com/#!/news/42https://example.com/#!/news/42
A bare hash-bang droppedhttps://example.com/a#!https://example.com/a
An escape of a plain character decodedhttps://example.com/%7Euser/%41https://example.com/~user/A
Other escapes in upper casehttps://example.com/caf%c3%a9https://example.com/caf%C3%A9
Non-ASCII escapedhttps://example.com/caféhttps://example.com/caf%C3%A9
A dot segment removedhttps://example.com/a/./bhttps://example.com/a/b
A double-dot segment removes the one before ithttps://example.com/a/../bhttps://example.com/b
An escaped double dot, decoded first, then removedhttps://example.com/a/%2E%2E/bhttps://example.com/b
An empty path becomes a slashhttps://example.comhttps://example.com/
Tracking parameters removed, the others kept in orderhttps://example.com/a?b=2&utm_medium=social&a=1&gclid=Xhttps://example.com/a?b=2&a=1
Empty parameters removedhttps://example.com/a?a=1&&b=2&https://example.com/a?a=1&b=2
A query left empty dropped, with its question markhttps://example.com/a?utm_source=newsletterhttps://example.com/a

What stays two links

These are not merged. Each is its own Article.

DifferenceOne linkThe other
With www. and withouthttps://www.example.com/ahttps://example.com/a
With a final slash and withouthttps://example.com/ahttps://example.com/a/
A plus and an escaped spacehttps://example.com/a?q=a+bhttps://example.com/a?q=a%20b
An escaped slash and a slashhttps://example.com/a%2Fbhttps://example.com/a/b
Capitals in the pathhttps://example.com/Ahttps://example.com/a
The parameters in another orderhttps://example.com/a?b=1&a=2https://example.com/a?a=2&b=1
A parameter that is not on the tracking listhttps://example.com/a?ref=homehttps://example.com/a
Capitals in a tracking namehttps://example.com/a?UTM_Source=xhttps://example.com/a
Two different hash-bang pageshttps://example.com/#!/ahttps://example.com/#!/b

Links that are refused

Where a rewrite would be a guess, the link is refused and the operator gives the spelling they mean.

A linkWhy
http://example.com/aThe link is not https.
https://user:secret@example.com/aIt carries a user name or password.
https://example.com./aIts host ends with a dot.
https://bücher.example/aIts host is not ASCII; give its xn-- spelling.
https://[::1]/aIts host is an IPv6 address.
https://example.com/a bIt holds a space or a control character.
https://example.com/100%A percent sign that starts no escape: whether it meant itself is a guess.

Tracking parameters

A query parameter whose name starts with a prefix marked * or is exactly a name below is dropped: it is added by whoever shared the link, not by the publisher. Names are matched in lower case only. The list is fixed.

ParameterAdded by
utm_*Google Analytics campaign tags, set by whoever shares the link
_glGoogle Analytics' cross-domain linker
_hsencHubSpot email
_hsmiHubSpot email
dclidGoogle Campaign Manager and Display & Video 360
fbclidFacebook and Messenger, on an outbound click
gbraidGoogle Ads, on an iOS app-to-web click
gclidGoogle Ads, on an ad click
igshidInstagram, on a shared link
li_fat_idLinkedIn Ads
mc_cidMailchimp: the campaign
mc_eidMailchimp: the recipient of the email
mkt_tokMarketo email
msclkidMicrosoft Advertising
ttclidTikTok Ads
twclidX (Twitter) Ads
wbraidGoogle Ads, on an iOS web-to-app click
yclidYandex Direct