• .md 문서가 생성될 때 사용되는 template을 수정하고 테스트 글을 작성합니다. (Update: Dec 16, 2019)

Configurations

  • OS: Windows 10 (x64)
  • Browser: Google Chrome
  • Hugo: v0.61.0
  • Hugo theme: hugo-tranquilpeak-theme (0.4.7-BETA)

Edit template, default.md & compose the new document

1. Hugo new {filename}.md 파일을 생성할 때 참조되는 template을 수정합니다

; 아래 default.md 내용을 그대로 사용해도 되고 필요한 것만 선택하여 작성해도 됩니다
수정 파일: \Hugo\blog\archetypes\default.md
참조 파일: \Hugo\blog\themes\hugo-tranquilpeak-theme\archetypes\post.md

 S:\Hugo\blog> more archetypes\default.md
 ---
 title: "{{ replace .TranslationBaseName "-" " " | title }}"
 date: {{ .Date }}
 draft: true
 categories:
 - category
 - subcategory
 tags:
 - tag1
 - tag2
 keywords:
 - tech
 #thumbnailImage: //example.com/image.jpg
 ---
 
 <!--more-->

2. Hugo new {filename}.md 또는 기존 md 파일 복사해서 작성하는 방법

2.1. hugo new 로 template 를 이용해 새로운 md 파일을 생성하고 작성할 수 있습니다
md 파일의 위치는 blog\content 폴더로, 초안이 아닌 공개할 문서는 하위 post 폴더에 작성하면 됩니다
비공개와 같은 (작성중)초안 문서를 draft 폴더로 분류하는 경우도 볼 수 있지만 md 파일내 ‘draft: true’ 로 명시되어 있으면 그 md 문서는 public 폴더에 반영되지 않습는다

S:\Hugo\blog> hugo new post/test1.md
Hugo\blog\content\post\test1.md created

2.2. blog\content 폴더 내 기존 md파일을 복사, 수정하여 사용해도 됩니다
단, 파일명은 중복되면 안되며, md 파일 내 생성시간을 원하는 값으로 바꾸면 됩니다

S:\Hugo\blog\content\post> cp test1.md test2.md
S:\Hugo\blog\content\post> notepad test2.md
(...)
title: "Editing template and Posting first"
date: 2019-12-16T00:03:15+09:00
draft: true
(...)

2.3. hugo 의 문서 삭제는 content 폴더와 html로 변환 저장된 public 폴더에서 파일을 삭제하면 됩니다

2.4. notepad와 같은 편집기로 md 파일을 저장할 때 인코딩을 반드시 UTF-8 로 저장해야 합니다
흔히 메모장 앱에서 옵션 변경없이 저장되는 ANSI 일 경우 html 변환시 오류가 발생됩니다

3. Run hugo on local

; hugo server -D
*display also draft documents with -D option

s:\0_GithubPages\Hugo\blog> hugo server -D
Building sites  WARNING: calling IsSet with unsupported type "string" (string) will always return false.

                   | EN-US
+------------------+-------+
  Pages            |    48
  Paginator pages  |     0
  Non-page files   |     0
  Static files     |    11
  Processed images |     0
  Aliases          |    17
  Sitemaps         |     1
  Cleaned          |     0

Built in 207 ms
Watching for changes in s:\Hugo\blog\{archetypes,content,data,layouts,static,themes}
Watching for config changes in s:\Hugo\blog\config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

4. 브라우저에서 확인

http://localhost:1313/