How to stop Google indexing my Github repository

后端 未结 4 1164
忘掉有多难
忘掉有多难 2020-12-07 09:42

I use Github to store the text of one of my web sites, but the problem is Google indexing the text in Github as well. So the same text will show up both on my site and on Gi

相关标签:
4条回答
  • 2020-12-07 10:14

    Short awnser. Yes you can with robots.txt.

    If you want to prevent Googlebot from crawling content on your site, you have a number of options, including using robots.txt to block access to files and directories on your server.

    You need a robots.txt file only if your site includes content that you don't want search engines to index. If you want search engines to index everything in your site, you don't need a robots.txt file (not even an empty one).

    While Google won't crawl or index the content of pages blocked by robots.txt, we may still index the URLs if we find them on other pages on the web. As a result, the URL of the page and, potentially, other publicly available information such as anchor text in links to the site, or the title from the Open Directory Project (www.dmoz.org), can appear in Google search results.

    Sources:

    http://support.google.com/webmasters/bin/answer.py?hl=en&answer=93708 http://support.google.com/webmasters/bin/answer.py?hl=en&answer=156449

    0 讨论(0)
  • 2020-12-07 10:21

    simple answer: make your repo private.

    https://help.github.com/articles/making-a-public-repository-private

    0 讨论(0)
  • 2020-12-07 10:27

    The https://github.com/robots.txt file of GitHub allows the indexing of the blobs in the 'master' branch, but restricts all other branches. So if you don't have a 'master' branch, Google is not supposed to index your pages.

    How to remove the 'master' branch:

    In your clone create a new branch - let's call it 'main' and push it to GitHub

    git checkout -b main
    git push -u origin main
    

    On GitHub change the default branch (see in the Settings section of your repository) or here https://github.com/blog/421-pick-your-default-branch

    Then remove the master branch from your clone and from GitHub:

    git branch -d master
    git push origin :master
    

    Get other people who might have already forked your repository to do the same.

    Alternatively, if you'd like to financially support GitHub, you can go private https://help.github.com/articles/making-a-public-repository-private

    0 讨论(0)
  • 2020-12-07 10:28

    If want to stick to the master branch there seems to be no way around using a private repo (and upselling your GitHub account) or using another service that offers private repos for free like Bitbucket.

    0 讨论(0)
提交回复
热议问题