Hexo(헥소) 블로그 검색엔진 최적화 플러그인

Hexo 블로그 검색엔진 최적화를 위한 RSS 피드와 사이트맵, robots.txt 생성 등 필수적인 플러그인을 설치하고 설정

hexo 검색엔진 최적화 블로그인 설치 및 설정

설치할 plugins

  1. hexo-generator-feed
  2. hexo-generator-seo-friendly-sitemap
  3. hexo-generator-robotstxt
  4. hexo-autonofollow
  5. hexo-auto-canonical

RSS fedd (rss feed 생성기)

plugins: hexo-generator-feed

npm install hexo-generator-feed --save

_config.yml 설정

# Rss feed
feed:
  type: atom # atom or rss2
  path: atom.xml
  limit: 50 # 공개할 rss feed 수
  # 기본적으로 여기까지만 쓴다. 아래는 옵션
  hub:
  content:
  content_limit: 140 # 요약 글자수
  content_limit_delim: ' '

sitemap(사이트맵 생성기)

plugins: hexo-generator-seo-friendly-sitemap

npm install hexo-generator-seo-friendly-sitemap --save

_config.yml 설정

# sitemap auto generator
sitemap:
    path: sitemap.xml
    tag: true # 사이트맵에 태그 주소 포함 여부
    category: true # 사이트맵에 카테고리 주소 포함 여부

robots.txt(로봇 텍스트 생성기)

plugins: hexo-generator-robotstxt

npm install hexo-generator-robotstxt --save

_config.yml 설정

# robots.txt
robotstxt:
  User-agent: "*"
  Allow: /
  Sitemap: https://계정명.github.io/sitemap.xml

nofollow (외부 링크에 nofollow 속성을 추가 / 로봇이 외부 링크는 수집하지 않도록)

plugins: hexo-autonofollow

npm install hexo-autonofollow --save

_config.yml 설정

#nofollow
nofollow:
  enable: true

포스팅에 외부 링크가 있으면 rel="external nofollow noopener noreferrer" 속성이 자동으로 생성된다.

<a href="https://hexo.io/plugins/index.html" rel="external nofollow noopener noreferrer" target="_blank">https://hexo.io/plugins/index.html</a>

canonical (유사하거나 중복된 페이지의 표준 페이지 정의)

plugins: hexo-auto-canonical

npm install hexo-auto-canonical --save

HTML 소스 수정하기

헥소 기본 테마는 layout\_partial\head.ejs
hueman 테마일 경우 layout\common\head.ejs
파일을 열고 <head> 아래에 아래 코드를 삽입 위치는 상관없지만 마지막 메타태그 아래에 넣는다.

hueman 테마일 경우 마지막 메타태그인 <%- meta(page) %> 이거 아래에 삽입함.

//ejs
<%- autoCanonical(config, page) %>

//jade(pug) 템플릿 사용 테마는 아랫것
!{ autoCanonical(config, page) }

브라우저에서 소스를 보면 아래 속성이 head에 추가된 것을 볼 수 있다.

 <link rel="canonical" href="https://계정명.github.io/">  
반응형