블로그 개발 쉽게하기 (with. hugo)
hugo 최신버전 설치하기
우분투에서 $apt-get install hugo 로 물론 설치할 수 있다.
하지만 이렇게 설치하면 0.94.0이 최신버전이 된다. ReLearn 테마를 설치하기 위해서는 0.95.0 이상 버전의 휴고가 설치되어야 하기때문에 다른 방법을 찾아야한다.
1. go 최신버전 설치 및 환경변수 세팅
https://go.dev/dl/
이 사이트에서 최신버전의 go를 찾을 수 있다. 링크만 따와서 우분투에서 wget으로 가져온다
$ wget [download link] # ex) go1.20.linux-amd64.tar.gz
$ sudo tar -xvf [go_tar_file]
$ sudo mv go /usr/local/
# 환경변수 세팅 .profile의 맨 아래에 export 추가
$ vi .profile
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:
$ source .profile
$ go version
2. go로 hugo 빌드 및 설치
hugo는 일반버전과 extended 버전이 따로 있다. 특정 테마를 이용하기 위해서는 Sass/SCSS 컴파일을 지원하는 extended 버전을 설치해야한다.
# 일반버전
$ go install github.com/gohugoio/hugo@latest
# extended 버전
$ CGO_ENABLED=1 go install --tags extended github.com/gohugoio/hugo@latest
$ hugo version
퀵스타트 (+테마설정)
원하는 테마를 https://themes.gohugo.io/ 사이트에서 고른 후 아래의 방식으로 적용하면 된다.
nohup 을 이용해서 서버를 켜면 현재 터미널이 종료되더라도 계속 실행된다.
# 휴고 레파지토리 파기
$ hugo new site [folder]
$ cd [folder]
$ git init
$ git config --global user.name "kimdong"
$ git config --global user.email "parktest0325@gmail.com"
$ git remote add origin [remote]
# 테마설정
$ git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke
$ echo "theme = 'ananke'" >> config.toml
# 실행
$ nohup hugo server --bind="0.0.0.0" &
# 글쓰기. 아래 명령 이후 vim으로 열어서 내용 작성
# 디폴트 draft 옵션이 true라서 -D 옵션을 포함해서 서버를 켜야 보인다.
$ hugo new posts/my-first-post.md
서브모듈(테마) 삭제하는 방법
$ git submodule deinit -f themes/hugo-book
$ rm -rf .git/modules/themes/hugo-book
$ rm -rf themes/hugo-book
# git add, commit 을 진행해야 삭제되고 다시 다른 테마를 적용할 수 있다.
테마를 직접 clone 받아서 설치해도 적용은 되지만, 나는 내가 직접 테마를 커스텀하고 관리할 예정이기 때문에 테마개발자의 레포를 fork 하고, 내 레포를 submodule로 지정했다.
Comments