Hexo에서 Hugo로 블로그 엔진 변경

기술블로그 엔진을 Hexo에서 Hugo로 바꾸어 보았다.

Hexo에 Icarus 태그를 씌우고 도커에 올려서 잘 쓰고 있었는데 내가 사용한 도커 이미지는 업뎃이 안된다는 문제가 있었다. https://github.com/spurin/docker-hexo

그래서 비슷한 엔진인 Hugo를 찾아보았는데 Hugo의 도커 이미지는 관리가 잘 되고 있었다. https://hub.docker.com/r/klakegg/hugo/

근데 이상하게도 이 이미지를 비롯한 모든 hugo의 도커 이미지는 내 시놀로지 환경에서 실행이 안됐다. 짜증나기도 하고 이왕 이렇게 된거 로컬에서 실행하기로 했다. 맥북에서 하면 brew를 사용하기 때문에 업뎃도 쉬워서 관리가 편하다. hexo가 brew로 관리가 안된다는 점도 hugo로 온 이유중에 하나. Go를 쓰니까 빠르다는 점은 그렇게까진 다가오지 않았다.

# hugo 초기화

1
2
$ brew install hugo  // hugo를 인스톨
$ hugo new site [생성할 폴더 이름]

# 깃 준비

1
2
3
4
5
6
$ cd cliearl.github.io
$ git init
$ git remote add origin [https://hugo 원본파일을 보관할 저장소]
$ git submodule add https://github.com/cliearl/cliearl.github.io.git public
$ git submodule add https://github.com/CaiJimmy/hugo-theme-stack.git themes/stack
$ git submodule update --init --recursive  // 테마가 업데이트 될 경우 반영

# 새로 설정하는 경우

1
2
3
4
5
6
$ git pull [https://hugo 원본파일을 보관할 저장소]
$ git rm --cached public
$ git rm --cached themes/stack
$ git submodule add https://github.com/cliearl/cliearl.github.io.git public
$ git submodule add https://github.com/CaiJimmy/hugo-theme-stack.git themes/stack
$ git submodule update --init --recursive  // 테마가 업데이트 될 경우 반영

# 글 작성 후 확인

1
2
$ hugo new posts/test.md  // 새로운 글 작성
$ hugo server  // 만들어진 정적사이트를 localhost:1313에 띄워줌

# 페이지 작성 후 업로드

1
2
3
4
5
$ hugo -t [테마이름]  // 정적사이트 생성
$ cd public
$ git add .
$ git commit -m "deploy updates"
$ git push origin main

# 커밋 자동화 스크립트

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

# Build the project.
hugo -t zzo

# Go To Public folder
cd public
# Add changes to git.
git add .

# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

# Push source and build repos.
git push origin main

# Come Back up to the Project Root
cd ..


# blog 저장소 Commit & Push
git add .

msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

git push origin master

# 검색엔진에 등록

# Google Search Console

  • Google Search Console에 접속
  • 속성 추가 후 URL 접두어에서 github.io 주소 입력
  • HTML파일로 확인 선택 -> 파일 다운로드
  • hugo의 public 폴더에 복사하면 루트에 업로드 됨
  • 소유권 확인됨

# config.toml 수정

1
2
3
4
5
6
7
# 로봇 검색 허용
enableRobotsTXT = true

# 사이트맵 작성
[sitemap]
changefreq = "daily"
filename = "sitemap.xml"

# 서치콘솔에 등록

Sitemaps 메뉴에서 …/sitemap.xml을 등록.

Licensed under CC BY 4.0
Last updated on Aug 13, 2023 21:50 KST
Built with Hugo
Theme Stack designed by Jimmy