3

I'm trying to provide link preview support for a site I run that folks use to troubleshoot some of their code. My goal is to show, in the Stack Overflow post the URL is posted on, the code and translation that can be found at the URL on my site.

I'm looking for any documentation on how to do this. I can't find anything, despite a lot of searching.

15
  • 1
    Link previews are generally possible with APIs based on the Open Graph protocol (for instance). But I’m not sure what you mean by “simply show the code” — which code exactly do you want to show? “and [its] translation” — Which translation? Based on which translation API? Translation of code or of paragraphs? Commented Mar 17, 2021 at 2:35
  • Thanks for the response Sebastian. Does StackOverflow use Open Graph for its link previews? Commented Mar 17, 2021 at 2:37
  • 1
    of course it does - you can open devtools and see all the necessary og: meta tags for both answers and questions Commented Mar 17, 2021 at 2:40
  • Oleg, apologies. My question was not clear. I'm trying to get link previews working inside of Stack Overflow posts. If I post a codepen.io URL, then I get a preview showing the code at that codepen.io URL. I want to make it so that links to my site on Stack Overflow posts have link previews as well. My question is more like "how does the Codepen.io link preview work?". Because I want to do something similar. Commented Mar 17, 2021 at 2:46
  • 1
    @michaelavila (btw, please do @-mentions, or the reply can easily be missed) - ah, so you want an external link to show up as a preview (I initially read your question exactly the opposite way)? Never thought that codepen's links generate a preview in posts (mostly because I use stack snippets proper) - can you point to such a post to get a grasp on? Commented Mar 17, 2021 at 3:00
  • 1
    @OlegValter I didn't realize these mentions worked, thanks! Learning more than I expected. :) Here's an example post with codepen stackoverflow.com/questions/42142323/cant-align-image-with-div. This little project I've had for years does a very simple translation over some code for a particular community and it's useful. Links to my project already show up on stack overflow in a few places and I just want to make it more useful to that community. Thanks again for your time. Commented Mar 17, 2021 at 3:05
  • 3
    NP. Re:post - wait a second, are you talking about the snippet that's showing up in the question? That's a Stack Snippet - the user just took the time to copy-paste the code required for the snippet to work - other than that, I don't see any previews - can you clarify? Commented Mar 17, 2021 at 3:09
  • Hm, shoot. Ok, so it looks like I can't do this then. I mistook what I was seeing as a kind of link preview. Sorry about that! I appreciate your time. Commented Mar 17, 2021 at 3:12
  • 1
    @michaelavila no worries - yeah, I think this is just a Stack Snippet, no magic here, unfortunately. You can try to create a feature request in another post on Meta, but be very detailed and specific. Most likely it will drown with the rest of the feature requests recently, though. Commented Mar 17, 2021 at 3:15
  • 1
    @OlegValter actually, here's another page I've been looking at that has me scratching my head: stackoverflow.design/product/components/link-previews . This makes me think something like this is possible, but I can't find any other info anywhere. Commented Mar 17, 2021 at 3:15
  • 1
    @michaelavila - yes, the design kit has this as a component, so it could be a nice basis for a feature request since the component already exists (and developer time costs seem to be the main deterrent for any feature suggested to SE). Commented Mar 17, 2021 at 3:33
  • 6
    See Testing GitHub Oneboxes for Stack Overflow for Teams. This is already being tested, and may be extensively used on Stack Overflow for Teams, but for Stack Overflow main, keep in mind that a minimal reproducible example is still required for questions and answers also must be self-contained. Commented Mar 17, 2021 at 3:35
  • 1
    @SebastianSimon thank you. So, if I understand correctly, this is something I could support for links that get posted in Stack Overflow for Teams, but on Stack Overflow main this functionality does not exist. Let me know if I have that wrong. Commented Mar 17, 2021 at 3:49
  • 1
    @SebastianSimon - I seem to have missed that one, thank you. michaelavila - you can still build your request around bringing the feature to the Public Platform (this is how we are called as opposed to Teams). Just be sure to address the concerns already mentioned by Sebastian - posts with such links being self-sufficient. With that, and the fact that it is tested on Teams, the feature may have a good chance of being expanded to public SO (we have examples of this). At a quick glance, it looks like an interesting feature to have. Commented Mar 17, 2021 at 3:57
  • 1
    @OlegValter I'll give that a go. I need to do some research and get it written up somewhere. Thanks for your help! Commented Mar 17, 2021 at 4:22

0

You must log in to answer this question.

Browse other questions tagged .