Skip to main content

구글에서 지킬 블로그가 검색되도록 설정하기


구글에서 지킬 블로그가 검색되도록 설정하는 방법이다.


1. google search console 접속 & 인증

google search console 로 들어가서 본인 소유 블로그의 url 입력

캡처


구글에서 제공하는 인증용 html 파일 다운로드 (본인 소유인지 확인하기 위해)

캡처1


html을 본인 블로그 디렉토리의 루트폴더에 집어넣고 깃허브 업로드 후 인증하면

소유권이 자동으로 확인되었다는 창이 뜨게된다.

캡처2



2. sitemap.xml 생성

루트 디렉토리에 sitemap.xml 파일을 생성하고 아래의 내용을 넣어준다.

---
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 %}
<url>
<loc>https://syki66.github.io</loc>
{% if post.lastmod == null %}
<lastmod></lastmod>
{% else %}
<lastmod></lastmod>
{% endif %}

{% if post.sitemap.changefreq == null %}
<changefreq>weekly</changefreq>
{% else %}
<changefreq></changefreq>
{% endif %}

{% if post.sitemap.priority == null %}
<priority>0.5</priority>
{% else %}
<priority></priority>
{% endif %}

</url>
{% endfor %}
</urlset>

만약 baseurl을 사용하고 있다면 loc 태그 부분에 아래와 같이 쓰면 된다.

<loc>{{ site.url }}{{ site.baseurl }}{{ post.url }}</loc>


3. robots.txt 생성

루트 폴더에 robots.txt 파일을 생성하고 아래의 내용을 넣어준다.

User-agent: *
Allow: /

Sitemap: https://syki66.github.io/blog/sitemap.xml

sitemap.xml은 사이트를 크롤링 하기 쉽게 만들어주고, robot.txt로 크롤링 허용 범위 설정 및 사이트맵을 쉽게 가져가도록 해준다. (robots.txt 사용법)



4. sitemap.xml 제출

google search consoleSitemaps 메뉴에 들어가서 sitemap.xml을 제출

image


그러면 아래의 사진처럼 성공했다고 표시가 되며, 몇시간 안에 구글 검색으로 블로그가 노출되게 된다.

image



참고자료