# Allow and/or automatically construct relative and anchor links

(scroll to the last section for the proposed change summary)

Rationale:

• When linking to the same site, there's no real need to insert the site's name
• The unnecessary part takes up (limited) message space and makes it harder to use the other protocol

Anchor links also have one particular use case that's not covered now:

I feel it would be optimal if such links are generated automatically from full URLs - because all current engine facilities only provide full URLs and it would be impractical to force users to truncate them by hand every time.

This shouldn't be an excessive load on server any more than the already live mangling of links to some sites like amazon.com.

There is some support already, as animuison noted, but it's severely lacking:

• Relative (/questions/example) and protocol-relative (//meta.stackexchange.com/questions/example) URLs are supported in raw syntax but not by the Hyperlink wizard in the editing UI.
• Anchor links (#comment910907_280538→example) are not supported at all.

To summarize, the proposed changes are:

• Hyperlink wizard shall support relative and anchor links
• It shall auto-truncate full URLs as much as possible
• truncate links to the same SE site to relative
• truncate links to entities in the same question to anchor links
• (discussable) truncate links to other SE sites to protocol-relative
• (discussable) convert links to some known external sites to protocol-relative or enforce a specific protocol in line with Make all i.stack.imgur.com links protocol-relative
• (discussable) Markdown shall do the above, or some of the above, upon rendering
• Permalinks (/q/ and /a/) and human-readable links shall be treated the same with regard to the above automatic conversions
• by Hyperlink wizard
• (discussable) by Markdown
• I've been reluctant to do this manually because I'm concerned about content reuse under CC license. Requiring reusers to auto-rewrite relative URLs — and having to do the same thing ourselves in cases of question migrations! — is somewhat less than ideal. – Nathan Tuggy Jun 23 '16 at 21:11