Do you host your Jekyll generated site on Github and need to distinguish between Github and other environments, where the site has been built?

Github exposes repository metadata inside Jekyll’s configuration under site.github namespace. This can be used to render some interesting data like repository name, organisation members, releases, contributors or repositories:

{% for repository in site.github.public_repositories %}
  * [{{ repository.name }}]({{ repository.html_url }})
{% endfor %}

Or you can use it to detect Github powered build and modify your templates accordingly:

{% if site.github %}
    <p>Hosted on Github Pages, for free.</p>
{% endif %}

Instruct search engines to ignore github build

I am hosting this blog myself on my hosting while keeping github page as an online backup. In this case is needed to tell search engines, which site should be ignored. To do so, my robots.txt looks like:

{% if site.github %}
User-agent: *
Disallow: /
{% else %}
User-agent: *
Allow: /
{% endif %}

And in HTML header of the layout:

{% if site.github %}
    <meta name="robots" content="noindex, nofollow">
{% endif %}

The self-hosted page (build by travis-ci) is fully accessible and indexable. The github page should be ingored and not indexed by search engines.