cgy12306

Hugo Setting 본문

카테고리 없음

Hugo Setting

cgy12306 2021. 2. 1. 21:07
  1. windows용 git 설치

  2. hugo release 설치

    https://github.com/gohugoio/hugo/releases/tag/v0.79.0

  3. C:\Hugo\bin 디렉토리를 생성 후 여기에 압축 해제

  4. 환경 변수 설정

  5. hugo version 명령어가 잘 먹히는지 확인

프로젝트 생성

  1. 프로젝트를 생성할 디렉토리를 하나 생성
  2. hugo new site [프로젝트이름]

템플릿

  1. https://themes.gohugo.io/ 에서 맘에 드는 템플릿 하나 선택

  2. 다운로드 버튼을 누르게 되면 코드가 있는 깃허브 홈페이지로 들어가게 됨

  1. 깃 코드 주소 복사

  2. themes 디렉토리에 들어가서 git clone [주소] 명령어 입력

  1. config.toml 파일 내용에 theme = "테마이름" 추가 혹은 제공해주는 테마로 설정 후 변경 (되도록이면 Readme에 나와있는대로 하는 것을 추천)

글 생성

  1. hugo new [파일이름.md] 명령어 입력

  2. contest 디렉토리가 새로 생기며 [파일이름]으로 된 마크다운 문서가 새로 생기게 됨

미리보기

  1. 프로젝트 디렉토리로 이동하여 hugo server -D 명령어 실행

    -D 옵션은 마크다운 파일이 수정되면 자동으로 갱신하여 제공

  1. localhost:1313에 접속하면 페이지가 뜨게 됨

ERROR 2020/12/10 21:27:49 render of "page" failed: execute of template failed: template: _default/single.html:5:7: executing "_default/single.html" at <partial "head" .>: error calling partial: "C:\Hugo\test\test\themes\hugo-geekdoc\layouts\partials\head.html:18:29": execute of template failed: template: partials/head.html:18:29: executing "partials/head.html" at <index .Site.Data.assets "main.min.css">: error calling index: index of untyped nil ERROR 2020/12/10 21:27:49 render of "section" failed: execute of template failed: template: _default/list.html:5:7: executing "_default/list.html" at <partial "head" .>: error calling partial: "C:\Hugo\test\test\themes\hugo-geekdoc\layouts\partials\head.html:18:29": execute of template failed: template: partials/head.html:18:29: executing "partials/head.html" at <index .Site.Data.assets "main.min.css">: error calling index: index of untyped nil Built in 28 ms Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: _default/list.html:5:7: executing "_default/list.html" at <partial "head" .>: error calling partial: "C:\Hugo\test\test\themes\hugo-geekdoc\layouts\partials\head.html:18:29": execute of template failed: template: partials/head.html:18:29: executing "partials/head.html" at <index .Site.Data.assets "main.min.css">: error calling index: index of untyped nil

위와 같은 에러가 뜨게 되면 템플릿에 문제가 있는 것이므로 테마 디렉토리 안에 있는 파일들을 확인하거나 config.toml 설정 파일을 확인해보는 것이 좋음

git blog 생성

  1. 내용을 담을 repo 하나와 블로그(github.io)가 되는 repo 생성

  2. git remote add origin [내용을 담을 repo 주소]

  3. git submodule add -b master [github.io repo 주소] public

    명령어를 입력하면 public 디렉토리가 하나 생성됨. 이 디렉토리가 github.io 저장소와 연결됨

  4. hugo -t [테마명]

  5. cd public

  6. git add .

  7. git commit -m "메세지"

  8. git push origin master

  9. cd ..

  10. git add .

  11. git commit -m "메세지"

  12. git push origin master

Comments