Hugo
éçãµã€ããžã§ããŒã¿ HugoïŒãã¥ãŒãŽïŒã«ã€ããŠãŸãšããŠããŸãã
詳现ãªæ¥æ¬èªèª¬æãµã€ããã§ããŠãããããç°¡åãªèª¬æã«çããŠããŸãã
詳ãã説æã¯å¿
èŠã«å¿ããŠæ€çŽ¢ããŠã¿ãŠäžããã
äŸãã° ð Let’s Encrypt ã® Web ãµã€ã㯠Hugo ãæ¡çšãããŠããŸãã
 letsencrypt/website | GitHub
ç®æ¬¡
å ¬åŒã»é¢é£ãµã€ã
- Â Hugo - å
¬åŒãµã€ã
- Hugo Documentation - ããã¥ã¡ã³ã
- Hugo Themes - ããŒã
-  Hugo Community - æ²ç€ºæ¿
- æ¥æ¬èª - æ¥æ¬èªã§ãæçš¿å¯èœã§ã
- Â GitHub - gohugoio / hugo
- Â Twitter - @GoHugoIO
ã€ã³ã¹ããŒã«
SASSã»SCSS ãçæããããŒããå¢ããŠããã®ã§ã
åºæ¬çã« Hugo Extended ãã€ã³ã¹ããŒã«ããã®ãããããã§ãã
ææ°çã§ã¯ SCSS ãçšããŠããªãããŒãã§ãæ£åžžã«ãã«ãã§ããŸãã
GitHub ããçŽæ¥å®è¡ãã¡ã€ã«ãããŠã³ããŒãããpath ãéããŸãã
 Releases | GitHub - gohugoio/hugo
Homebrewã»Chocolateyã»Scoop ã䜿çšããŠããå Žåã¯ã
ãã¡ãããããã±ãŒãžã€ã³ã¹ããŒã«ãå¯èœã§ãã
 Install Hugo | Hugo Documents
Windows ã§ã¯ PowerShellã»ã³ãã³ã ããã³ããã»Git Bashã
macOS ã§ã¯ ã¿ãŒããã« ãªã©ãèµ·åãã次ã®ã³ãã³ããå
¥ããŸãã
hugo version
Hugo Static Site Generator vïœ ã®è¡šç€ºã§ã€ã³ã¹ããŒã«ã§ããŠããŸãã
ã¢ããã°ã¬ãŒãã»ããŠã³ã°ã¬ãŒã
GitHub ããå®è¡ãã¡ã€ã«ãããŠã³ããŒãããå Žåã¯ã
åãæ¹æ³ã§ææ°çãããŠã³ããŒããããã¡ã€ã«ãäžæžãããŠäžããã
åé¡ããã£ãŠå€ãããŒãžã§ã³ã«æ»ãããå Žåãåæ§ã§ãã
Scoop
ð Scoop | ãµãããð FU-SEN
Scoop ãçšããŠããå Žåã容æã«ã€ã³ã¹ããŒã«ã§ããŸããmain
ãã±ãããªã®ã§ãScoop ãã€ã³ã¹ããŒã«ãããŠããã°ã
æ®éã«ã€ã³ã¹ããŒã«å¯èœã§ãã
scoop install hugo-extended
extended ãä»ããªã hugo
ãååšããŸãã
scoop install hugo
webinstall.devã»webi
 Hugo | webinstall.dev
ð webinstall.devã»webi | ãµãããð FU-SEN
webinstall.dev ã§ææ°çãããŠã³ããŒãããã®ã¯
Windows ãçšããŠããå Žåã¯æ¬¡ã®ã³ãã³ãã§ãã
curl.exe https://webi.ms/hugo-extended | powershell
Windows 以å€ã®å Žåã次ã®ã³ãã³ãã§ãã
curl -sS https://webi.sh/hugo-extended | sh
webi ãã€ã³ã¹ããŒã«ããŠããå Žåã¯ã
次ã®ã³ãã³ãã§ææ°çãã€ã³ã¹ããŒã«ããŸãã
webi hugo-extended@stable
webi hugo-extended@0.102.2
ãªã©ãšããŒãžã§ã³æå®ãå¯èœã§ãã
Extended çã§ã¯ãªã Hugo ãã€ã³ã¹ããŒã«ã§ããŸãã
curl.exe https://webi.ms/hugo | powershell
curl -sS https://webi.sh/hugo | sh
webi hugo@stable
hugo-bin
 hugo-bin | npm
 fenneclab/hugo-bin | GitHub
ãã€ããªãŒã¬ãã«ã®ã©ãããŒã§ããnpm ã³ãã³ã㧠Hugo ãã€ã³ã¹ããŒã«ã§ããŸãã
Hugo ã®æŽæ°ããæ°æéïœæ°æ¥ã§ããŒãžã§ã³æŽæ°ãããŠããŸãã
ãã ã hugo-bin ã®ããŒãžã§ã³ã¯ Hugo ãšé£åããŠããŸããã
æŽæ°ç¢ºèªã¯ npm ã GitHub ãããžã§ã¯ãã®ã¿ã°ãèŠãå¿
èŠããããŸãã
npm i -g hugo-bin
ã€ã³ã¹ããŒã«ãªãã·ã§ã³ã䜿çšã㊠extended çãã€ã³ã¹ããŒã«å¯èœã§ãã
Web ãµã€ãã»ããã°ã®æ°èŠäœæ
ããã§ã¯äžã€ Web ãµã€ãã»ããã°ãäœæããŠã¿ãäºã«ããŸããcd å Žæ
㧠Web ãµã€ãã»ããã°ã®æ§æãã¡ã€ã«ã眮ãå Žæã«ç§»åããŸãã
è€æ°ç°å¢ã®å
±æãããã¯ã¢ãããç®çã« Dropbox ãªã©ã䜿ã£ãŠãè¯ãã§ãããã
次ãå®è¡ããŸãããµã€ãå ã¯ãã£ã¬ã¯ããªïŒãã©ã«ãïŒã«ãªããŸãã
ãã®ããããµã€ãå ã¯è±æ°ãç¡é£ã§ãã
ãµã€ãéå¶è
㯠ãã¡ã€ã³åïŒgohugo.jp.eu.org ãªã©ïŒã«ããŠããŸãã
hugo new site ãµã€ãå
ããŒãã決ããŸãã
ããŒãã®è©³çŽ°ããŒãžãã Download ãŸã㯠Homepage ã§
GitHib ã®ãããžã§ã¯ãããŒãžã衚瀺ãããŸãã
ãã®ããŒããã¡ã€ã«ã git clone
ãŸã㯠git submodule add
ã§ããŠã³ããŒãããŸãã
cd ãµã€ãå/themes/
git clone ãªããžããª
ããŒããã¡ã€ã«ã®ãã£ã¬ã¯ããªã«å
¥ããšãexampleSite/ ãã£ã¬ã¯ããªãããäºãå€ãã§ãã
ãã® exampleSite/ å
ã ãµã€ãå/ äžã«ã³ããŒããŸãã
ãã®æ config.toml ã¯äžæžãããŠæ§ããŸãããããã§æºåãæŽããŸããã
éåžžäœæ¥
è¿œå ã»å€æŽã¯ cd ãµã€ãå
ã§ç§»åããŠãããŸããconfig.toml
ãšè€æ°ã®ãã©ã«ãïŒãã£ã¬ã¯ããªïŒããããšããã§ãã
hugo server
ãå®è¡ãããš Web ãµãŒããèµ·åããŸãã
Web ãã©ãŠã¶ãã http://localhost:1313/ ãåç
§ãããšãå®æãããç¶æ
ã§åç
§ã§ããŸãã
ãµãŒããèµ·åãããŸãŸãã¡ã€ã«ãç·šéããŸãã
ãã¡ã€ã«ä¿å㧠Web ãã©ãŠã¶ã®è¡šç€ºã«å³åæ ãããŸãã
äž»ã«æ¬¡ã®ãšãããè¿œå ã»ç·šéããäºã«ãªããŸãã
-  config.toml - ãµã€ãå šè¬ã®èšå®
-  content/ å - ããŒãžã»ããã°èšäºïŒé垞㯠.md ãã¡ã€ã«ïŒ
- static/ å - ç»åã»JavaScriptã»CSS ãªã©ïŒãã®äžã¯ãã®ãŸãŸã³ããŒãããŸãïŒ
äœæ¥å®äºæ㯠Ctrl
+C
ã§ãµãŒãåäœãåæ¢ã§ããŸãã
å®æãããšããã§ãcd ãµã€ãå
ãžç§»åã
ïŒ config.toml
ãšè€æ°ã®ãã©ã«ãïŒãã£ã¬ã¯ããªïŒããããšããïŒ
次ã®ã³ãã³ãã§ãã«ãããŸãã
hugo
ãã®æ  Minify ãå¯èœã§ãã
public/ å
ã« index.html
ãªã©ãçæãããŸãã
ããšã¯çæããããã¡ã€ã«ãã¢ããããŒãããŸãã
PHP ãªã©ã¯äœ¿ãããŠããªããããå€ãã® Web ãµãŒãã§å
¬éã§ããŸãã
FTP ã§ã¢ããããŒãããŠãããã§ããã
Hugo æ¡çšã«åãããŠãµãŒããå€æŽãããšå
¬éãå¿«é©ã§ãã
 Category: hosting and deployment | Hugo Documents
 CLI ã«ããã¢ããããŒãã»å
Ž
ãªããèšäºã®ã¿ã€ãã«ãå€æŽããå Žåãªã©ã¯äœ¿çšããªããã¡ã€ã«ãçºçããŸããã
Hugo 㯠public/ å
ã®ãã¡ã€ã«ãåé€ããŸãããæåã§åé€ããå¿
èŠããããŸãã
 'hugo clean' #2389 | GitHub gohugoio/hugo issues
ãã©ã«ãã»ãã£ã¬ã¯ããªæ§æ
hugo new site ãã©ã«ãå
ã§çæãããã©ã«ãïŒãã£ã¬ã¯ããªïŒå
ã¯
次ã®å
容ã§æ§æãããŠããŸããããã¯ããŒãå
±éã§ãã
archetypes/
ããã©ã«ãã§ã¯ default.md
ããå
¥ã£ãŠããªãã§ããããhugo new èšäºãã¡ã€ã«.md
ã®æã«åç
§ããããã³ãã¬ãŒããã¡ã€ã«ã§ãã
å€ãã®ããŒãã§ã¯ããã«è¿œå ããŸããããç¬èªã®ãã¡ã€ã«ãè¿œå ã§ããŸãã
content/
ããã°ã§ããèšäºãã¡ã€ã«ãå
¥ããŸããéåžž Makrdown .md
ãã¡ã€ã«ã§ãã
çŸåšã¯ãã©ã«ããäœæããŠãé¢é£ããç»åãã¡ã€ã«ãªã©ãäžç·ã«å
¥ããäºãã§ããŸãã
éåžž content/
çŽäžã¯ public/
çŽäžã§çæãããŸãããconfig.toml
ã« [permalinks]
ãå ããå Žåã¯ãçæãå€åããŸãã
[permalinks]
post = "/:year/:month/:slug/"
ãã®å Žå content/post/
å
ã®ãã¡ã€ã«ã¯ public/
å
ã§2021/02/èšäºå/
ã§çæãããŸãã
_index.md
ã index.html
çžåœã«ãªããŸãã
ããã°ã§ã¯ãªã Web ããŒãžçšéã§ãããããŒãžã®çæã§å¿
èŠã«ãªããŸããã
äžèŠ§è¡šç€ºã«å¯Ÿå¿ããŠããããŒãã§ãååŸã«ããã¹ããè¿œå ã§ããå ŽåããããŸãã
ãªããHugo ã§ã¯äŒçµ±çã«ããã°é¢é£ã¯ content/post/
ãæ¡çšããããŒããå€ãã§ãã
data/
ããŒã¿ãã¡ã€ã«ãããã«å
¥ããäºã§ããã«ãã§åŠçãããäºãã§ããŸãã
äžéšã®ããŒãã§äœ¿çšãããŠããäºããããŸãããéåžžã¯ããŸã觊ããäºããªãã§ãããã
layouts/
å€æŽãããã³ãã¬ãŒããã¡ã€ã«ãå
¥ããŸãã
ãªãªãžãã«ã¯ themes/ããŒãå/layouts/
å
ã«ãããlayouts/
ã«å
¥ãããã¡ã€ã«ã¯ãã®ããŒãã«ãããã¡ã€ã«ãäžæžãé©çšããŸãã
layouts/
çŽäžã public/
çŽäžã§ãã
éåžžã¯ãã®ãŸãŸæ§æãããã¡ã€ã«åã«ãªã£ãŠããŠãindex.html
ã 404.html
ãªã©ããããŸãã404.html
㯠Not Found 衚瀺ã§ãã
partials/
ã¯çŽ°ããããŒãæ¯ã«çœ®ããŠãããŸãã
ããŒãã«ãã£ãŠæ§æãç°ãªããŸããããããã次ã«ãªããŸãã
- head.html -
<head>
é¢é£ - header.html - ããŒãžäžéš
- footer.html - ããŒãžäžéš
contents/post/
ãªã©ã contents/
äžéšã«ãã©ã«ããããå Žåã
該åœãããã©ã«ãåã layouts/
ã«ãªãå Žå㯠_default/
ãåç
§ããŸããlayouts/
å
ã« post/
ãããšããã®ãã©ã«ããæç·é©çšãããŸãã
æ§æãã¡ã€ã«ã¯äž»ã«æ¬¡ã®ãã¡ã€ã«ã§ãã
- list.html - èšäºäžèŠ§ïŒãã©ã«ãå ïŒ
- sinple.html - èšäºããŒãž
ãã®ä»ãããŒãã«ãã shortcodes/
ãããã
ç¹å®ã®åºåã容æã«èšèŒããæ¹æ³ããããŸãã
ããŒãã䜿çšããªãå Žåã¯ããã«ãã³ãã¬ãŒããã¡ã€ã«ãæ§ç¯ããäºã«ãªããŸãã
public/
hugo
ã§çæããã HTML ãã¡ã€ã«ãšç»åãã¡ã€ã«ãªã©ãããã«å
¥ããŸãã
ããããµãŒããžå
¬éããŸãã
åºåå
ã public/
ããå€æŽããå Žå㯠config.toml
ã« publicDir
ã§æå®ããŸãã
resources/
hugo
å®è¡ãã¡ã€ã«ãäžæãã¡ã€ã«çæã«äœ¿çšããŸãã觊ããäºã¯ãããŸããã
static/
ããã«å
¥ãããã¡ã€ã«ã¯ãã®ãŸãŸ public/
ãžå
¥ããŸããrobots.txt
ã favicon.ico
apple-touch-icon.png
ã
JavaScript ã CSS ãã¡ã€ã«ãéåžžã¯ãã¡ãã§ãã
ç»åãã¡ã€ã«ã¯ãã¡ãã«å ¥ããŠã®äœ¿çšãå¯èœã§ãã
ãªããHugo ã¯ããã©ã«ãã§ãµã€ãããã sitemap.xml
ãçæããã®ã§ã
ããã¯æåã§çæããå¿
èŠã¯ãããŸããã
themes/
éåžžãã®ä»®æ³ã« git clone URL
ãŸã㯠git submodile add URL
ãšããŠ
ããŒããã¡ã€ã«ãå
¥ããŸãã
å®å
šã«çæããå Žåã¯ããã䜿çšããŸãããthemes/
ã®äžã¯éåžžãã¡ã€ã«ç·šéããªãã§äžããã å€æŽããå Žåã¯ã³ããŒããŸãã
ãã䜿ãã®ã¯ themes/ããŒãå/layouts/
å
ãã layouts/
å
ãžã®ã³ããŒã§ãããã
exampleSite
ãããããŒããå€ãã§ãã
çæãããã©ã«ãã®æ§æã«åãããŠã³ããŒãããšããã¢ããŒãžãåçŸã§ããŸãã
config.toml
èšå®ãã¡ã€ã«ã§ãããµã€ãå
±éã®èšå®ã¯ããã«å
¥ããŸããããŒãã®æå®ãªã©ãè¡ããŸãã
ããŒãã«ãã£ãŠ config.yaml
ããããŸãã
ãã®ä»
ãã以å€ã¯ Hugo ã¯é垞䜿çšããŸããã
å¿
èŠãªå Žåã¯é¢é£ãã¡ã€ã«ã»ãã©ã«ããçæã§ããŸããã
åœç¶ GitHub ãªã©ã§ãããžã§ã¯ãå
¬éããå Žåã¯ããããå
¬éãããŠããŸãã®ã§ã
èæ
®ãå¿
èŠã§ãã
ãã¡ã€ã«æ§æ
ããŒãã«ãã£ãŠãã¡ã€ã«æ§æã¯å€ãã£ãŠããŸãã
ããã§ã¯æ¯èŒçããŒãã§å
±éããŠããå
容ã§æäœé觊ãããšããã説æããŸãã
config.toml
config.yaml
ã§å
¬éããŠããããŒãããããŸãã
baseurl = "https://example.net.eu.org/"
publicDir = "public"
title = "Hugo ã®ã€ããããã"
theme = "whiteplain"
languageCode = "ja"
defaultContentLanguage = "ja"
disableKinds = ["taxonomy","taxonomyTerm"]
- baseurl å
¬é URLïŒæ«å°Ÿ
/
ã®æç¡ã¯ exampleSite ã®èšèŒã«åãããŠïŒ
baseurl ã«ã¯ãã£ã¬ã¯ããªãå«ããäºãå¯èœã§ããbasedir = "https://example.org/dir/"
ã®å Žåhugo server
㯠http://localhost:1313/dir/ ã§ãã - publicDir index.html ãªã©ã®åºåå ãéåžžã¯ååšãã public/ ãžåºå
- title ãµã€ãå
- theme 䜿çšããããŒãåïŒthemes/ããŒãå/ ã§åç §ïŒ
- languagecode æ¥æ¬èªã®å Žåã¯
ja
ïŒhtml ã¿ã°ã® lang ã§äœ¿çšãããå ŽåããïŒ
â»ja-JP
ã䜿ããããja
ã¯æ¥æ¬èªèšèªãã¡ã€ã«ãé©çšããããŒããååšãã - defaultContentLanguage æ¥æ¬èªã®å Žåã¯
ja
- disableKinds ã«ããŽãªã»ã¿ã°ã䜿çšããªãå Žåã¯
["taxonomy","taxonomyTerm"]
â» æå®ããªãå Žåãäœããªãã«ããŽãªã»ã¿ã°ããŒãžã RSSã»ãµã€ããããã«å ¥ã£ãŠããŸã
RSSã»ãµã€ããããã䜿çšããªãå Žåã¯["RSS","sitemap","taxonomy","taxonomyTerm"]
æŽã«ããŒãç¬èªã®èšå®ãšã㊠[params]
ã®é
ç®ãç¶ããŸãã
ãªããtoml ã§ã¯ã"""
ã§å²ãäºã§è€æ°è¡ã§èšèŒãã§ããŸãã"
ã®åã« \
ãä»ããå¿
èŠããããŸãããHTML ã Markdown ã䜿ããé
ç®ã«äŸ¿å©ã§ãã
copyright = """
Copyright © 2021
<a href="https://balloon.asia/" target="_blank">ãµãããð FU-SEN</a>
"""
content/ å
hugo new ããŒãžå.md
㧠archetypes/default.md ãå
ã« content/ããŒãžå.md ã§çæãããŸãã
ãã§ã« .md ãã¡ã€ã«ãããå Žåãã³ããŒããŠãæ§ããŸããã
ããã°ã¯éåžž content/post/ å
ã§ããhugo new post/ããŒãžå.md
ãšãªããŸãã
index.html ã«è©²åœããã®ã¯ _index.md ãšãªããŸããïŒé ã® _
ã«æ³šæïŒ
ããã§ã¯ yaml ã§ã®èšèŒã§ãã---
ã +++
ã«ãããš toml ã«ãªããŸãã
---
title: "Hugo ã®ã€ããããã"
slug: "Hugoã®ã€ãããã"
date: 2021-05-08T16:20:00+09:00
categories:
- web
- ããã°
tags:
- Hugo
- CSS
- Blog
- ããã°
keywords:
- Hugo
- CSS
description: "Hugo ã«ã€ããŠã®çŽ¹ä»ã"
weight: 10
draft: false
---
- title ããŒãžåã»èšäºã®ã¿ã€ãã«
- slug URL 衚瀺ãã£ã¬ã¯ããªåïŒãã¡ã€ã«åïŒÂ ããŒãž URL ãå€æŽãããã®ã§ããâŠâŠ
- date æ¥ä»ãçŸåšããæªæ¥ã ãšéå
¬éãæ«å°Ÿ
+09:00
ã§æ¥æ¬æšæºæ - category ã«ããŽãªãäºã€ä»¥äžã®å Žåãäºã€ç®ä»¥éã¯ãµãã«ããŽãªæ±ã
- tags ã¿ããè€æ°æå®å¯èœ
- keyword ããŒã¯ãŒããããŒãã«ãã meta ã¿ã°ã«äœ¿çšããã
- description ããŒãã«ãã meta ã¿ã°ã«äœ¿çšããã
- weight 䞊ã³é ãã¡ãã¥ãŒãªã©ã§äœ¿çšãWeb ãµã€ãã§ã¯å¿ é
- draft true ã®æã¯äžæžãã
hugo server -D
ã§åç §ã§ãã
ãã®ä»ãããŒãžã»èšäºå¥ã®ç»åãé ç®ã«ããå Žåãå€ãã§ãããããç»åãš OGP ã«äœ¿ãããŸãã
ãã¹ãŠèšèŒããå¿
èŠã¯ãããŸãããå€ãã¯çç¥å¯èœã§ãã
æå°é㯠titleã»dateãæ¥ä»è¡šç€ºããªããã° title ã®ã¿ã«ãªããŸãã
draft ã䜿ãããã«èšèŒãããŠããäºãå€ãã§ããã
ãµã€ãéå¶è
㯠draft ã䜿ã£ãŠããŸããã
ãªããã° draft: false ã«åãã§ã-D ãªãã§ã衚瀺ã»å
¬éã®å¯Ÿè±¡ã§ãã
---
title: "Hugo ã®ã€ããããã"
date: 2021-05-08T16:20:00+09:00
---
# Hugo ã®ã€ããããã
éçãµã€ããžã§ããŒã¿ **Hugo** ïŒãã¥ãŒãŽïŒã«ã€ããŠãŸãšããŠããŸãã
æ¬æ㯠Markdown ã§èšèŒããŠãããŸããåãæ¶ãç· ãªã© GitHub Flavored MarkdownïŒGFMïŒãæå¹ã§ãã
ð Markdown | ãµãããð FU-SEN
ã¡ãã¥ãŒ
Hugo ã§ã¡ãã¥ãŒæ©èœãååšããŠãããããå€ãã®ããŒãã¯ãããæ¡çšããŠããŸãã
contect/ å
ã® .md ãã¡ã€ã«ã§èšèŒããæ¹æ³ãšãconfig.toml ã«èšèŒããæ¹æ³ããããŸãã
content/ ã® .md ãã¡ã€ã«ãã¡ãã¥ãŒã«è¡šç€ºããå Žåã¯æ¬¡ã§ãã
ããã§ã¯ date ãªã©ãçç¥ããŠããŸãã
---
title: "Hugo ã®ã€ããããã"
type: "top"
menu: "main"
weight: 1
---
config.toml ã«èšèŒããå Žåã¯æ¬¡ã§ãã
ãã®å Žå name ã§èªç±ã«ã¡ãã¥ãŒã®è¡šç€ºåãä»ããããŸãã
ãŸã url 㯠/ïœ ã«ãããµã€ãå
ãhttps:// ã«ããå€éšãæå®ã§ããŸãã
[[menu.main]]
name = "Hugo ã®ã€ããããã"
weight = 1
identifier = "top"
url = "https://example.net.eu.org/"
ããŒãã«ãã£ãŠã¯ç¬èªã®ç°ãªãæ¹æ³ã§å®è£ ããŠããå Žåãããäºã«ã泚æäžããã
Minify
HTML ãªã©ã®äœèšãªç©ºçœã»æ¹è¡ããªãããŠè¡šç€ºã®é«éåãã§ããŸãã
ãã ããçææéããããã®ã§ãããŒãžæ°ã®å€ãããã°ãªã©ã¯ç¹ã«æ³šæããŠäžããã
hugo --minify
config.toml ã«è¿œå ããããã«å¯Ÿå¿ãããŠããããã§ããã
ãµã€ãéå¶è
ãè©Šããæãã§ã¯åäœããŠããªãããã§ãã
Cloudflare ã䜿çšããŠããå ŽåãCloudflare åŽã§ Minify ãå®çŸã§ããŸãã
æ¹è¡ã¯æ®ãããããããœãŒã¹ãèŠããã Minify ãšããæãã§ãã
ïŒãã¡ã€ã³éžæåŸãSpeed - Optimization - Auto MinifyïŒ
Web ãµãŒãã¹ã«ãã察å¿
Cloudflare Pages
 Cloudflare Pages
ð Cloudflare Pages | ãµãããð FU-SEN
2020幎12æããããŒã¿çå
¬éããã2021幎5æããæ£åŒå
¬éãšãªã£ãã
Cloudflare ã®æ°ãµãŒãã¹ã§ãã
GitHub é£æºã®ãããGitHub ã¢ã«ãŠã³ããå¿
èŠã§ãã
ãªããžããªã¯å
¬éå¿
é ã§ã¯ãªãããã©ã€ããŒããªããžããªã§ã䜿çšã§ããŸãã
ãã«ãããªã»ããã« Hugo ãååšãã
容æã« Hugo ã§ãã«ããã Web ãµã€ããå
¬éã§ããŸãã
ããã©ã«ã㯠Hugo 0.54 ãšå€ãããã®ãŸãŸã§ã¯ããŒããé察å¿ã®å ŽåããããŸãã
ç°å¢å€æ° HUGO_VERSION
ã§ããŒãžã§ã³ãæå®ã§ããã®ã§ã
ææ°ããŒãžã§ã³ãŸãã¯äœ¿çšããŠããããŒãžã§ã³ã«èšå®ããŠãããã«ãããŠäžããã
Vercel
â² Vercel
ð Vercel | ãµãããð FU-SEN
Vercel 㯠Hugo ã®ãã«ãã«å¯Ÿå¿ããŠããŸãã
â² Create a Hugo Website and Deploy It with Vercel | Vercel Blog
Hugo ã®ãã£ã¬ã¯ããªæ§æãã vercel --prod
ãŸã㯠GitHubã»GitLabã»Bitbucket ãžã® git push
ã§
Hugo ã®ãã«ããè¡ããå
¬éããŸãã
éåžž Vercel ã¯ã¯ãããŠãã«ããã段é㧠Hugo ãä»æ§ããŠããäºãèªåèªèãã
é©åãªãã«ããè¡ãããã现ããèšå®ãè¡ãå¿
èŠã¯ãããŸããã
Hugo ã®ããŒãžã§ã³ã§ä»æ§ãç°ãªãå Žåãããããã
䜿çšããŠãã Hugo ã®ããŒãžã§ã³ãæå®ããäºãããããããŸããvercel.json
ã§ç°å¢å€æ° HUGO_VERSION
ãèšå®ããŸãã次㯠0.101.0
ã«ããŠããŸãã
{
"build": {
"env": {
"HUGO_VERSION": "0.101.0"
}
}
}
Q&A
æ£åŒè¡šèšã¯ Hugo ãš HUGO ã©ã¡ãã§ããïŒ
HUGO ã¯ããŽã¿ã€ããšããŠäœ¿çšãããŠããŸããããŽãšå
¬åŒãµã€ãïŒgohugo.ioïŒã®å·Šäžã®ã¿ã§ãã
äžæ¹ Hugo ã¯å
šè¬çã«ããè¡šèšãããŠããŸãã
ãããã£ãŠãHugo ãå
¬åŒçãªäžè¬è¡šèš ãšå€æã§ããŸãã
ãããã€ããšãŠãã¯ãããšèããã®ã§ããïŒ
çŸåšèŠãŠãã ð balloon.asia ã¯
2022幎5æçŸåšãMarkdown ãªã©ã®ããŒãžã 210 ããŒãžãè¶
ããŠããŸããã
åæã® Core i5 ãã·ã³ã§ãæ°ç§ã§ãã«ããå®äºããŸãã
ïŒãããéå¶è
ã¯ãã€ãé³æ¥œãåç»ãåçããªããäœæ¥ããŠããŸãïŒ
Hugo ã«é¢ä¿ãªãããµãŒãã«ã¢ããããŒããããããã€ã®æ¹ãæéãèŠããŸãã
ãããªã«ãã«ãæéãã¯ããéçãµã€ããžã§ããŒã¿ãéå¶è
ã¯ä»ã«ç¥ããŸããã
ææ°çãçŽ æ©ãç¥ãæ¹æ³ã¯ãããŸããïŒ
GitHub ãªããžããªã«å ¥ããŸããGitHub ã¯ãã°ã€ã³ããŠãããŸãã
å³äž  Notifications éšåã Release only ã«å€æŽããŠäžããã
ããã«ããããã°ã€ã³ããŠãã GitHub ã¢ã«ãŠã³ãã®ã¡ãŒã«ã¢ãã¬ã¹ã«
ææ°ããŒãžã§ã³ãå
¬éãããã¿ã€ãã³ã°ã§éç¥ãå±ãããã«ãªããŸãã
ç»åãã¡ã€ã«ã¯ã©ãã«å ¥ããã°è¯ãã®ã§ããïŒ
static/
å
ã«å
¥ããã®ãäžã€ã®æ¹æ³ã§ãã
ãã®å Žå㯠public/
å
ã«ãã®ãŸãŸå
¥ããŸãã
ãŸãã contents/
å
ã«èšäºãšäžç·ã«ç»åãå
¥ããäºãã§ããŸãã
äŸãã° contents/åå/
ã§ãã£ã¬ã¯ããªãçæãã
ïŒååã¯èšäºåãªã©ã åå.md ã®ä»£ããã«ãã£ã¬ã¯ããªåãäœæïŒ_index.md
ã®èšäºãšäžç·ã«ç»åããŸãšããŸãã
ããã«ããèšäºãšç»åãåããã£ã¬ã¯ããªã«ããã®ã§ã
ç»åã®æå®ã¯ãã¡ã€ã«åã®ã¿ã«ã§ããŸãã
config ã® permalinks ãã 幎ã»æ ãã£ã¬ã¯ããªãçæããŠããå Žåã
ããã«åãããŠç»åãã¡ã€ã«ã眮ãã®ãæã§ãã
ã³ã¡ã³ãã¯ä»ããããŸããïŒ
Hugo 㯠config.toml ã®èšå®é
ç®ãšã㊠disqusShortname
ãçšæããŠããŠã
Disqus ã®è¿œå ã«å¯Ÿå¿ããŠããŸãããã®ãããå€ãã®ããŒã㯠Disqus ã«å¯Ÿå¿ããŠããŸãã
ã¹ããŒããã©ã³å¯Ÿå¿ã«ã§ããŸããïŒ
Hugo ã®ããŒãã¯ã»ãŒå
šãŠã¬ã¹ãã³ã·ã察å¿ã§ãã
ã¹ããŒããã©ã³ã§è¡šç€ºããæã¯æé©åãããããã«äœãããŠãããŸãã
ããœã³ã³ã§ãŠã€ã³ããŠã®æšªå¹
ãçž®ããŠã¿ããšåãããŸãã
Googlebot ã¯ã¢ãã€ã«å¯Ÿå¿ãšèªèããŸããå®å¿ããŠããŒããé©çšããŠäžããã
äžéšã®è¡šç€ºãããããã§ã
0.57 ããäžèŠ§è¡šç€ºã®ä»æ§ãå€ãã£ãŠããŸãã
ããŒãã察å¿ããŠããªãå Žåã衚瀺ããããããªããŸãã
WARN 衚瀺ãåºãŠããŸã
0.55 ããããŒãã§å€ãè¡šèšã®ãŸãŸã«ãªã£ãŠããå Žåã«çºçããŸãã
ããŠã³ããŒãããããŒãã§çºçããŠããå Žåã¯ã
ãã®ããŒãã® GitHub ãªããžããªãž issue ããŠä¿®æ£ãäŸé ŒããŠäžããã
ä¿®æ£ç®æ㯠layouts/ å ã®ãã³ãã¬ãŒãã«ãªããŸããããã§ã¯å ·äœçã«ã¯è§ŠããŸããã
.md ãã¡ã€ã«ã« HTML å ¥ããŠãèªèããŸãã
0.60 ãã config.toml ã«æ¬¡ãè¿œå ã㊠HTML ãèšèŒã§ããŸãã
ãããä»ããªããš HTML ã¿ã°ãã³ã¡ã³ãã«çœ®ãæããŠç¡å¹ã«ããŸãã
[markup.goldmark.renderer]
unsafe = true
HTML ãã¡ã€ã«ã«åºåãããªãã³ã¡ã³ãã¯ã©ã®ããã«ããã°è¯ãã§ããïŒ
ãã³ãã¬ãŒããã¡ã€ã«ã§ã¯åã« HTML ã®ã³ã¡ã³ã <!-- ïœ -->
ãæå¹ã§ãã
HTML ã§ã¯ãããçç¥ãããŸãã
cotnent/
ã«å
¥ãã .md
ãã¡ã€ã«ã§ã¯ã
ã³ã¡ã³ããå€æããããïŒããã©ã«ãïŒããã®ãŸãŸåºåãããŸãã
ã·ã§ãŒãã³ãŒãã§å¯ŸåŠããæ段ã䜿ããŸããlayouts/shortcodes/
å
ã«ä»»æã® ã³ãŒãå.html
ã§
次ã®äžèº«ãå
¥ãããã¡ã€ã«ãçæããŸãã
{{ if .Inner }}{{ end }}
comment.html
ã§äœæããå Žåã.md ãã¡ã€ã«å
ã¯æ¬¡ã®ã³ã¡ã³ãèšèŒãå¯èœã«ãªããŸãã
{{< comment ã³ã¡ã³ã >}}{{< /comment >}}
äžã®æ¹æ³ã§ãšã©ãŒã«ãªãå Žå㯠"ã³ã¡ã³ã"
ãš "ïœ"
ã§å²ã£ãŠäžããã
{{< comment >}}ã³ã¡ã³ã{{< /comment >}}
äžã®æ¹æ³ã¯è€æ°è¡èšèŒã§ããŸãã
ãã®æ¹æ³ã¯ Hugo å
¬åŒãµã€ã㧠todo.html
ãšããŠå®éã«äœ¿ãããŠããŸãã
 layouts/shortcodes/todo.html | GitHub gohugoio/hugoDocs
匷å¶æ¹è¡ãããå Žåã¯ïŒ
Hugo ã® .md ãã¡ã€ã«å ã§ã¯ãæ¹è¡ãå ¥ããŠãæ¹è¡ãããŸããã空çœã«ãªããŸãã
æ¹è¡ãããå Žåã¯ãè¡æ«ã»æ¹è¡çŽå㧠\
ïŒåè§ ïŒŒ ãŸã㯠åè§ ï¿¥ïŒãå
¥ãããã
åè§ã¹ããŒã¹ã 2 æåå
¥ããŸãã
HTML ãæå¹ã«ããŠããå Žå㯠<br>
ã䜿ããŸãã
TOCïŒTable Of ContentïŒã§èªèãããªãèŠåºããäœãã«ã¯ïŒ
HTML ã® <h1>
ïœ<h6>
ã¿ã°ã¯ TOC ã§èªèãããŸããã
ããŒãž URL ãå€æŽãããã®ã§ããâŠâŠ
config.toml 㧠permalinks ã䜿çšããŸãã
ãªãå Žåã¯è¿œå ãããå Žåã¯å€æŽããŸãã
éåžžããã°ã§äœ¿ããã content/post/ å
ã Web ãµã€ãã®ããã«äœ¿ãç®çã§https://ãµã€ã/ã¿ã€ãã«/
ã«ãããå Žåã¯æ¬¡ã®ããã«ããŸãã
[permalinks]
post = "/:title/"
æ¥æ¬èªãæå¹ãª URL ãšããŠæ£ããåäœããŸããã
ãµãŒãã«ãã£ãŠäžå
·åãããå ŽåããããŸãã
ãŸã FTP ã§ã¢ããããŒãããå Žåãã¡ã€ã«åãå€æããªãã§äžããã
/:year/:month/:slug/ ã /:year/:filename/ ãšããæå®ãã§ããŸãã
:slug 㯠 content/ å
ã®é
ç®ãšã㊠slug ãå
¥ããäºã§ã
ããããã£ã¬ã¯ããªåïŒãã¡ã€ã«åïŒã«ãªããŸãã
ãªãå Žå㯠title ãæ±ãããŸãã®ã§ãé垞㯠titleã
å¿
èŠã«å¿ã㊠slug ä»å ãšããå Žåã§ã :slug ã䜿ããŸãã
 URL Management | Hugo Documents
éåžžã® Web ãµã€ããšããã°ãåããããµã€ããæ§ç¯ã§ããŸããïŒ
ã§ããŸããå®éåç
§ããŠãã ð balloon.asia ããã®æ§æã§ãã
config.toml ã® permalinks ã次ã«èšå®ããŠããŸãã
[permalinks]
post = "/:year/:month/:slug/"
content = "/:slug/"
ð post/ ãããã°ã ð content/ ãè€åã³ã³ãã³ãã§ãã/contents/_index.md
㯠/layouts/index.html
ã§èšäºããŒãžã«è¿ããã®ã«ããŠã
éåžžã®ããã¹ããèšèŒããŠããŸãã
æŽã«ãã³ããšã㊠/layouts/_default
㯠post
ã» content
å
±éã§ããã/layouts/post
ã§çæãããš post
ã/layouts/content
ã§çæãããš content
å
ã§ã®äžèŠ§ã»èšäºããŒãžã«ãªããŸãã
ãã®èŸºãã§ããããã«ãªããšãHugo ã§æ¬æ Œçãªãµã€ãæ§ç¯ãã§ããã§ãããã
Hugo ã®æ±ãã«æ
£ããŠããããã£ã¬ã³ãžããŠã¿ãŠäžããã
ç¬èªã® CSS ãå«ãããå Žåã¯ã©ã®ããã«ããã°è¯ãã§ããïŒ
ããŒãã«ãã£ãŠç°ãªããŸããäž»ã«æ¬¡ã®ããããã§ãã
- config.toml 㧠customCSS ãªã©ã®é
ç®ãããå Žåã
.css åãèšèŒããstatic å ã«çæããŸãã - themes/static/css/ å
ã«ç©ºã® custom.css ãªã©ãããå Žåã
ããã static/css/ å ã«å ¥ããŠè¿œå ããŸãã - ããããèŠã€ãããªãå Žå㯠themes/ããŒãå/layouts/partials/ å
ã確èªãã
head ã¿ã°å ãèšèŒããŠãã html ãã¡ã€ã«ãèŠã€ãåºã㊠layouts/partials/ å ã«å ¥ãã
CSS ãè¿œå ããããè¿œèšããŸããhead.html ã«è¿œèšããå Žåãå€ãã§ãã - themes/ããŒãå/layouts/partials/ å
ã«ãªãå Žåã¯
themes/ããŒãå/layouts/_defaults/baseof.html ã«èšèŒãããŠããŸãã
baseof.html ã layouts/partials/_defualts/ å ã«å ¥ããè¿œèšããŸãã
OGP ãå ãããã®ã§ããïŒ
ð Open Graph protocol | ãµãããð FU-SEN
å®ã¯ Hugo ã®å
éšãã³ãã¬ãŒããšã㊠OGP ãš Twitter ã«ãŒããåãã£ãŠããŸãã
æ¥æ¬ã§ã¯ OGP ãšèšèŒãããã®ã§ãããè±èªã§ã¯éåžž Open Graph è¡šèšã§ãã
 Internal Templates  Open Graph | Hugo
ãããããããç¥ããªãã®ããããŒãã§ã¯æå€ãšäœ¿ãããŠããŸããã/layouts/partials/head.html
ãªã©ã®ãããéšåã§ããããå ããŸãã
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
ãããã OGP ã䜿çšãããªããç»åãé©çšãããã§ãããã
ç»å㯠images
ã§ãããè€æ°ã®ç»åãæå®ã§ããããã«ãªã£ãŠããŸããconfig.toml
ã§ã¯æ¬¡ã®è¡šèšã§ããçç¥æã®ç»åã«ãªããŸãã
[params]
images = ["/images/ogp.png"]
èšäºãã¡ã€ã«ãªã©ã® .md ãã¡ã€ã«ã§å
¥ãã Front Matter éšåã§
é垞䜿ãããŠãã YAML ã§ã¯æ¬¡ã®è¡šèšã§ããããã§èšäºæ¯ã«ç»åãå€ããããŸãã
---
images:
- /images/ogp.png
---
SNS ãªã©ã§ã¯éèŠèŠçŽ ã«ãªããŸãã®ã§ãå
¬éåã« hugo server
ãããœãŒã¹ã衚瀺ãã
ç®çã®åºåãããŠããããã確èªããŠäžããã
ããŒãã«ãã£ãŠã¯ç¬èªã« OGP ã®å®è£ ãè¡ã£ãŠããå ŽåããããŸãã
ããã°ããŒãã Web ãµã€ãåãã«äœ¿çšã§ããŸããïŒ
å¯èœã§ãããã¡ãã£ãšæéãå¿
èŠã§ãããŒãã«ãã£ãŠå¯Ÿå¿ãç°ãªããŸãã
themes/ããŒãå/layouts/index.html ãå€æŽããå¿
èŠããããŸãã®ã§ã
layouts/index.html ãžã³ããŒããŠç·šéããŸãã
äž»ã«æ¬¡ã®ããããã«ãªããŸãã
- themes/ããŒãå/layouts/single.html ãšåçã«çœ®ãæããŸãã
- é©åãªå Žæã«
{{ .Content }}
ãå ããŸããããã« .md ãã¡ã€ã«ã®å 容ãå ¥ããŸãã
å®å
šã« .md ãã¡ã€ã«ã®å
容ã«ããå Žåã¯ãèšäºäžèŠ§è¡šç€ºéšåãåé€ããŸããã
ãããŠèšäºäžèŠ§è¡šç€ºãæ®ããŠããŒãžã®ã¡ãã¥ãŒäžèŠ§ã«æ¹è¯ããäºãã§ããŸãã
ãã®å Žå .md ãã¡ã€ã«ã§ weight ã䜿ã£ãŠè¡šç€ºé ãæå®ã§ããŸãã
ïŒweight 㯠date ãããåªå
ãããŸãïŒ
ããŒãžçæ㯠content/ çŽäžã« ãã¡ã€ã«å.md ã§çæãããã
次ã config.toml
ã«å
¥ããäžã§ content/post/ ã« .md ãã¡ã€ã«ãå
¥ããŸãã
å€ãã®ããŒãã§ã¯ post 以å€ã«ããäºãã§ããŸããã
äžéš post ã§äœ¿çšãããåæã§è£œäœãããŠããããŒãããããŸãã
[permalinks]
post = "/:slug/"
ãªããthemes å
ã¯ããŒãã®æŽæ°ã«äŒŽã£ãŠgit clone
ãŸã㯠git submodule update
ã§æŽæ°ããã®ã§ã
themes å
ã®ãã¡ã€ã«å€æŽã»åé€ãªã©ã¯è¡ããªãã§äžããã
Not Found ããŒãžã¯çæããŸããïŒ
Hugo ã§ã¯ Not Found ããŒãžã 404.html ã§èæ
®ãããŠããŸãã
Apache ãæ¡çšãããŠãããµãŒã㧠.htaccess ã䜿ããå Žåã¯ã次ã§é©çšã§ããŸãã
ErrorDocument 404 /404.html
ããŒãã§èæ
®ãããŠããå Žåãthemes/ããŒãå/layouts/404.html ãååšããŠããŸãã
ç¬èªã®ããŒãžã«ãããå Žå㯠404.html ã layouts/ å
ã«ã³ããŒããŠç·šéããŠäžããã
RSSã»ãµã€ããããã¯çæããŸããïŒ
RSS 㯠index.xmlïŒãã©ãŒããã㯠RSS 2.0ïŒããµã€ãããã㯠sitemap.xml ã§çæãããŸãã
ãµã€ãããã㯠date ã®æ¥æãåæ ãããã®ã§ãã¯ããŒã©ãŒã®åéã«ãå¹æçã§ãã
ãŸã config.toml
ã« enableRobotsTXT = "true"
ãå«ãããš robots.txt ãçæãããŸããã
ããã©ã«ãã§ã¯åã« 1 è¡ã® robots.txt
ãçæããŸãã
User-agent: *
Sitemap ãªã©ãå«ããããããããŠããã䜿ããã«static/
å
ãž robots.txt
ãäœã£ãŠãè¯ãã§ãããã
ããã㯠layouts/
å
ã§åãã³ãã¬ãŒããçæã§ããã®ã§ã
现ããå¶åŸ¡ããäºãã§ããŸãã
ð Hugo ã® robots.txt ãš Sitemapã| ãµãããð FU-SEN
çµµæåã§ã¯ãªãã¢ã€ã³ã³ã¯ã©ã®ããã«ããŠè¡šç€ºããã®ã§ããïŒ
Font Amesome ãå°å
¥ãããŠããããŒããå€ãã§ãã
äžé
ç®ã® HTML ãæå¹ã«ããäºã§ãi ã¿ã°ã« style ãå«ããŠè¡šç€ºã§ããŸãã
 Font Amesome
ð Font Awesome | ãµãããð FU-SEN
public ãã©ã«ãã®æ¥æããããããªã£ãŠããŸãã
 hugo creating invalid timestamps in folder public #6161 | GitHub gohugoio/hugo issues
é·ãçºçããŠããäžå ·åã§ãã
ãããåå ã§æŽã«å¥ã®åé¡ãçºçããŠããå Žåã¯ãhugo
å®è¡åŸã«ã³ãã³ã㧠public ãã£ã¬ã¯ããªã®æ¥æãæŽæ°ããŠäžããã
å€ãã® OS ãç°å¢ã§ã¯ touch
ã䜿ããŸããWindows ã§ã¯ Git Bash ãªã©ã§æå¹ã§ãã
hugo
touch public
Windows ã® PowerShell ã§ã¯ã次ã®ã³ãã³ãã§æŽæ°ããäºãã§ããŸãã
hugo
sp public LastWriteTime $(Get-Date)
.hugo_build.lock ãã¡ã€ã«ãçæãããããã«ãªããŸããã
 What is the .hugo_build.lock file? | Hugo Community
Hugo 0.89.0 ãããhugo ã®ã³ãã³ãå®è¡ã«ãã£ãŠ.hugo_build.lock
ãã¡ã€ã«ãçæãããããã«ãªããŸããã
ããã¯æ£åžžãªåäœã§ãããã¡ã€ã«ã¯ãã®ãŸãŸã«ããŠãããŠæ§ããŸããã
äŸãã° hugo server
ãå®è¡ããªãã hugo new ããŒãžå
ãå®è¡ãããªã©ã
è€æ° hugo
ã³ãã³ãåäœãè¡ã£ãå Žåã«åé¡ãçºçããããã«ãªã£ãããã.hugo_build.lock
ãã¡ã€ã«ã§ OS ã¬ãã«ã®ããã¯æäœãè¡ãäºã§ã
ãããé²ãããã«ããããšã®éçºè
ã®åçã§ãã