How To Embed Code Snippet In Blogger Blog Post Without Editing Template

There are several ways to add code box in Blogger blog posts. Many of them would suggest to edit blogspot template and add third-party CSS links. But I prefer a way that doesn’t require any tampering or modification of blogspot template.

First of all, it is risky & you may corrupt template HTML. Secondly, if later you want to move out of Blogger & host it in some other blogging platform like WordPress, that will break the formatting of the code block. You would have to add these CSS links in new template manually.

If you use proper HTML code without any third-party links for code display, that would be consistent & won’t break even if you move out of Blogger platform.

I am using website for highlighting my Java code blocks that I share here. It takes the Java code & pretty-prints it in HTML format. Then we can just copy & paste it in our Blogger blog post. It supports all the popular languages whether it is Java, Python, JavaScript, XML, Scala, Kotlin or MySQL. It can also colour highlight the code block & add line numbers to it. It will take care of adding scrolling too. Overall this website is pretty good & easy to use.

Leave a Comment