5

I often find myself linking to other posts in questions, answers, and comments. I almost always want to link to it with the question title, as in:

[question title](link to question)

The procedure to do this is something like:

  • Type []()
  • Go to tab I want to link to, select & copy the question title
  • Go back to the tab I'm typing in, paste it
  • Go back to other tab again, copy URL
  • back to previous tab, paste it.

...Repeat for every post you want to link to...

A small feature to copy the post's URL as markdown would be very helpful. Perhaps this can be done with the 'Share' box?

0

2 Answers 2

5

If you just want the title of the question, exactly as written, there is a bit of magic: just paste in the bare URL, and watch it magically title itself in the preview!

Just paste this question here like so:

https://meta.stackexchange.com/questions/254466/copy-link-to-a-post-as-markdown

and it renders like so:

Copy link to a post as markdown

(Check it out in the source if you're unsure exactly what I mean.)

It will even update itself if the question's title is ever edited.

This also works mid-paragraph and with punctuation touching the URL, so I can references your question "Copy link to a post as markdown" right here.


Note that this currently does not work in comments. To get it to work in comments, you can add the external userscript SE Comment Link Helper to do the job.

2

Although @SevenSidedDie's solution does work most of the time (+1!) - it won't work cross-site. So, in the (rare) case you want to share a link from another site, you can use this script that changes the link in the 'share' box to the form of markdown.

Obviously, this won't automatically update itself if the title ever changes, so only use this option if you're sharing a link cross-site!

$('.short-link').click(function() {
    setTimeout(function() {
        $('.share-tip input').val('[' + $('#question-header a').html() + '](' + document.URL + ')');
    }, 500);
});

You can get this script (and many more!) in my SE Optional Features userscript at StackApps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .