There are a couple of ways to do this. If you’re hosting your site on GitHub then the best way is to wrap your code or HTML inside:

  
    {% if jekyll.environment == 'production' %}
      ...
    {% endif %}
  

GitHub creates this environment variable on its servers.

But what if you’re hosting somewhere else or your site is already compiled by the time it’s uploaded to the server? In this situation you can just check for your environment client-side:

  
  <script type="text/javascript">
    if (window.location.hostname == 'example.com') {
      // ...
    }
  </script>
  

Most people have Javascript turned on… and do you really care about bots? In fact this javascript method is great for including analytics that you don’t want running on your local development environment.