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:
I use Codepen
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!
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 👌
Aw thanks Ed, really happy to hear that! Good luck with it!!!
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.)
Github Gists, plain simple, no pain point!
Github Gists work fine for me. Both the blogging platforms I use support it natively, and so does Medium, which makes life easy.
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.
Using Codesandbox for my JS newsletter https://rephrased.substack.com/
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.
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.
Strategies, tactics, and ideas for the bloggers among us!