Embed Gist Code Snippet on WP.com

One surprisingly difficult thing when writing articles on the web – posting source code samples. There are too many cases where the formatting, whitespace, and special characters are broken or missing when posted in a web article. I’m always looking for a better and easier way to post code samples here on WordPress.com. Here’s a little history from some of my past posts.

I am excited to post that I have a new potential solution / workaround for posting well-formatted code snippets. WP.com supports embedding GitHub Gist code posts into your blog articles. One drawback is that the code will not be searchable with the WordPress.com built-in search because the code is embedded with client-side javascript (essentially just a link to github). This also is a problem for search-engine friendly writing because the code will not be directly searchable with the associated blog post as Google’s search crawler will consider it a link or embed rather than written content on the page. To enhance your search-ability, try to include important code keywords and phrases in your blog post in addition to the actual github gist code. This GitHub Gist feature was announced April of 2012. More details on the official GitHub Gist code-snipppet Help page.


About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Technical Communication and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s