Bloggers October 18, 2020

Dev bloggers, where do you host code snippets? 🤔

Ed @SkepticalHippo

I'm in the process of writing a blog post and want to include a few code snippets, but can't find a decent place to host them.

Ideally, the snippets would be:

  • Easy to integrate
  • Interactive - either on-page or could go to a separate page to play around with them.

If it makes any difference - the code is JavaScript.

Any suggestions?

  1. 3


    I feel like Codepen and Codesandbox are the two main options you have, depending on how complex the code is you'd like to host.

    I've personally used neither but as a reader, I appreciate when either one is available to try something out!

    1. 1

      I'll have a look at Codesandbox, thanks!

      Fantastic work on Blogging for Devs by the way. Really enjoying it so far and happy I discovered it before publishing the blog post I'm working on now. Taking a bit of extra time to polish it according to your tips 👌

      1. 1

        Aw thanks Ed, really happy to hear that! Good luck with it!!!

  2. 2

    I've always used CodeSandbox.
    A great way to share the code while also showing a preview of the working code.
    CodeSandbox is especially handy when working with frameworks (React/Vue/etc.)

  3. 2

    Github Gists, plain simple, no pain point!

  4. 2


  5. 2

    Github Gists work fine for me. Both the blogging platforms I use support it natively, and so does Medium, which makes life easy.

  6. 2

    It probably depends which blogging system you are using. There are probably solutions to integrate files from Github or similar, but I have not really been in the need to. Keep your snippets minimal. This way there is no need to change them all the time.
    I a usually write in markdown and sprinkle minimal code snippets to it - not connected to Github or anything else. In the end I a mention a link to Github with the full code.
    For single files or small code blocks I use Gist. For multiple Files I create an extra repository.

  7. 1

    Using Codesandbox for my JS newsletter

    My biggest learning this week... There is only minimal analytics. I can only see number of views as far as I have worked out.

    Would love a code snippet hosting service with really great metrics to help really understand my blogs audience.

  8. 1

    I'd use CodeSandbox if I need to integrate the code into a blog post or a product documentation, but GitHub Gist if I'm just sharing a link (like in Twitter). The comment section of a Gist can give you useful feedback and suggestions on your code.

Recommended Posts