6

I have been using Alex Gorbatchev's Syntax Highlighter to display code snippets on my blog for the past couple of years. It serves the purpose, but it is a pain to add the code while blogging (I need to use a HTML Encoder and manually add this piece wrapped around a <pre> tag). But, the positive thing is, I know for sure the search engine will crawl the code I have written.

Recently I stumbled upon GitHub Gists and it was really easy to just copy & paste my code in, select the language, and use the embed code on my website. However, will search engines that crawl my blog be able to see the code inside my gist and be able to lead visitors to my blog page?

2
  • the title, yes, not contents Jul 24, 2012 at 12:49
  • My bet would be, that nowadas, Google uses the Chrome's engine to load pages, and indexes the actual resulting DOM, rather than the page source. Oct 10, 2023 at 22:34

2 Answers 2

4

From what I can see, gist.github.com uses javascript to embed gists such as:

<script src="https://gist.github.com/1234.js"> </script>

And although Google parses some javascript but I doubt 3rd party widgets would get parsed (see update below)

but this exact issue was discussed by Simon Bingham here. He suggests you use the "SEO Friendly Gists" tool which essentially grabs the embed code but ALSO generates a <noscript> version of the gist (that WILL be indexed by google)

Update:

Google Does some Javascript Parsing, and the only official resource I can find on this came from Best approach to have Google index content primarily generated by Javascript where they offer up:

https://developers.google.com/webmasters/ajax-crawling/

Which explains how to have ajax pages indexed.

I've haven't read anything about 3rd party widgets being parsed (nor have I seen any of them own my own sites get parsed) - I think google is focusing on building it's database not improving how your page renders.

If you find some official literature on this, please comment!

3
  • I thought Google did parse JavaScript. Check this article from 2011: googlewebmastercentral.blogspot.com/2011/11/… (furthermore, 2010: forbes.com/sites/velocity/2010/06/25/…)
    – Alpha
    Jul 26, 2012 at 23:39
  • I updated answer above
    – electblake
    Jul 27, 2012 at 0:54
  • 1
    For the last few years Googlebot has been including 3rd party JavaScript execution in its crawling and rendering. It may not have been at the time this answer was written, but as of 2022, data written into the page by third party JavaScript can get indexed, as long as the JavaScript that writes it is not blocked by robots.txt. Dec 8, 2022 at 13:44
1

I can confirm that the content from a github gist, embedded in a page counts as the page's content for Google. The good thing is that you can test it.

The following gist contains a specific/unique base64 encoded string which is embedded on a website (you can find it here and test it: https://timberlin.de/link-maskierung-javascript-base64/ [disclosure: the content was written by me]

enter image description here

Here is the google search result for it:

enter image description here

If you search in google for the specific string, the URL is shown as result. I.e. the indexing works and google renders the script.

3
  • /help/promotion May 7, 2023 at 6:54
  • @user: i have edited the post a bit and removed the example links - makes it a bit less helpful but the core message remains.
    – Tim Berlin
    May 7, 2023 at 7:57
  • you can still keep the links as long as you make a statement disclosing that the linked resource was written by you (assuming that it was) May 7, 2023 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.