githubPage google검색 가능하게 하기
January 19, 2018
/robots.txt 작성 CODE
User-agent: Googlebot
User-agent: DAUMOA
User-agent: NaverBot
Allow: /
Disallow: /diary/
User-agent: BadBot
Disallow: /
Sitemap: https://wiselotis.github.io/sitemap.xml
/sitemap.xml 작성 CODE
---
layout: null
----
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in site.posts %}
{% if post.sitemap %}
<url>
<loc>{{ site.url }}{{ post.url }}</loc>
{% if post.lastmod == null %}
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
{% else %}
<lastmod>{{ post.lastmod | date_to_xmlschema }}</lastmod>
{% endif %}
{% if post.sitemap.changefreq == null %}
<changefreq>weekly</changefreq>
{% else %} <changefreq>{{ post.sitemap.changefreq }}</changefreq>
{% endif %}
{% if post.sitemap.priority == null %}
<priority>0.5</priority>
{% else %}
<priority>{{ post.sitemap.priority }}</priority>
{% endif %}
</url>
{% endif %}
{% endfor %}
</urlset>
포스트 프론트에 sitemap 설정을 추가 robots.txt에서 disallow 할 수 있지만 나는 검색 될 포스트는 따로 sitemap 설정을 추가하는 방법으로 수정 하였다.
sitemap :
changefreq: daily
priority: 1.0
기존 코드에서.. sitemap설정이 있는 경우에만 크롤링 될 수 있도록 수정해주었다.
블로그를 기록겸 작성할꺼라서.. 검색될만한 좋은 정보가 아닐 수도 있고 해서..
여기서 주의 할 점!!
포스트의 프론트 작성시 아래와 같은 에러가 나올 수 있다.
이 에러는 내가 프론트 작성시 tab을 썼기 때문이다. YAML은 tab을 허용하지 않는다
sitemap :
[공백]changefreq: daily
[공백]priority: 1.0
공백 으로 바꿔주자
아직 블로그를 시작한지 얼마 안되서 모든게 낯설다..
나처럼 뭐지 하는 사람이 있을것 같아서..
사실 저 google캡처 잊어버려서 새로운 아이디로 들어가서 새로 캡처했다.
/Gemfile 에 jekyll-sitemap 추가
gem “jekyll-sitemap”
gem install
gem install jekyll-sitemap
127.0.0.1:4000/sitemap.xml 에서 확인
google 로그인 후 나의 웹 사이트 등록
google에서 down받은 확인용 html을 루트 아래에 복사
웹페이지를 닫지 말것
origin master에 push
git add –all
git commit -m “commit message “
git push -u origin master
다시 google 페이지로 돌아가서 확인 버튼을 클릭 하면 ~
성공
searchConsole > 크롤링 > sitemaps 에 들어가서
test 후 sitemap 제출