https://github.com/barryclark/jekyll-now
由于ruby 和bundler升级带来了jekyll一堆坑,终于决定迁移到hugo了
https://github.com/gohugoio/hugo
https://gohugo.io/
https://gohugo.io/tools/migrations/
% go get -u github.com/gohugoio/hugo
go: downloading github.com/gohugoio/hugo v0.91.2
../go/pkg/mod/github.com/gohugoio/hugo@v0.91.2/tpl/internal/go_templates/texttemplate/helper.go:11:2: package io/fs is not in GOROOT (/usr/local/Cellar/go/1.15.3/libexec/src/io/fs)
解决方案:
方案一:
1.下载go版本v1.16.5
2.解压到指定目录,如$HOME
3.编辑$HOME/.bashrc ,添加:
export PATH=$HOME/go/bin:$PATH
4.生效:
source ~/.bashrc
查看go 版本是否是v1.16.5
go version
6.重新执行go mod vendor,问题得到解决。
方案二:
使用更低版本的viper。
https://blog.csdn.net/init_zq/article/details/118637801
https://golang.google.cn/dl/
curl -O https://golang.google.cn/dl/go1.17.5.darwin-amd64.pkg
% /usr/local/go/bin/go version
go version go1.17.5 darwin/amd64
% vi .bashrc
export GOROOT=”/usr/local/go”
export PATH=”$PATH:$HOME/.rvm/bin:/usr/local/go/bin”
% source .bashrc
go get: installing executables with ‘go get’ in module mode is deprecated.
Use ‘go install pkg@version’ instead.
% hugo version
hugo v0.91.2 darwin/amd64 BuildDate=unknown
https://github.com/fredrikloch/JekyllToHugo
https://github.com/coderzh/ConvertToHugo
% python jekyllToHugo.py –help
Traceback (most recent call last):
File “jekyllToHugo.py”, line 35, in
import yaml
ImportError: No module named yaml
% pip3 install pyyaml
% python3 jekyllToHugo.py –help
usage: jekyllToHugo.py [-h] [-o OUTPUT] [-v] source
Options
positional arguments:
source Path to folder containing jekyll posts
optional arguments:
-h, –help show this help message and exit
-o OUTPUT, –output OUTPUT
Path to output folder, will be created if it does not exist. Defaults to content
-v, –verbose Print extra logging output
% python3 jekyllToHugo.py -o ./MyBlogSrc ~/MyBlogSrc
2022-01-02 17:02:18,554 - ERROR - Error parsing _includes could not get date
2022-01-02 17:02:18,554 - ERROR - Error parsing feed.xml could not get date
2022-01-02 17:02:18,555 - ERROR - Error parsing favicon.ico could not get date
2022-01-02 17:02:18,555 - ERROR - Error parsing index.html could not get date
2022-01-02 17:02:18,555 - ERROR - Error parsing .DS_Store could not get date
2022-01-02 17:02:18,555 - ERROR - Error parsing new.sh could not get date
2022-01-02 17:02:18,555 - ERROR - Error parsing LICENSE could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing category could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing about.html could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing css could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing _posts could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing js could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing .sass-cache could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing .bundle could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing 404.html could not get date
2022-01-02 17:02:18,556 - ERROR - Error parsing katex could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing push.sh could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing shareapi could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing slicebox could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing _layouts could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing token.js could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing 2017 could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing README.md could not get date
2022-01-02 17:02:18,557 - ERROR - Error parsing img could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing flash could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing temp.txt could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing .gitignore could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing sugarcookies could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing _site could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing _plugins could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing _config.yml could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing .github could not get date
2022-01-02 17:02:18,558 - ERROR - Error parsing replaceUrl.sh could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing Gemfile could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing head.html could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing Gemfile.lock could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing xiazemin.github.io could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing token.html could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing .git could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing test.dot could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing fonts could not get date
2022-01-02 17:02:18,559 - ERROR - Error parsing about.md could not get date
2022-01-02 17:02:18,560 - ERROR - Error parsing assets could not get date
2022-01-02 17:02:18,560 - ERROR - Error parsing tag could not get date
2022-01-02 17:02:18,560 - ERROR - Error parsing head.markdown could not get date
//自定义的头,解析不了
% mv head.markdown head.markdown.bak
https://cloudcannon.com/blog/jekyll-vs-hugo-choosing-the-right-tool-for-the-job/
https://gohugo.io/getting-started/quick-start/
% hugo new site MyBlogSrc
Congratulations! Your new Hugo site is created in /Users/xiazemin/source/MyBlogSrc.
Just a few more steps and you’re ready to go:
Visit https://gohugo.io/ for quickstart guide and full documentation.
下载一个相近的主题
https://themes.gohugo.io/themes/hugo-clarity/
% tree
.
|__archetypes
| |default.md
|content
|layouts
|static
|config.toml
|data
|__themes
https://zhuanlan.zhihu.com/p/37752930
cd MyBlogSrc
git init
已初始化空的 Git 仓库于 /Users/xiazemin/source/MyBlogSrc/.git/
git submodule add https://github.com/chipzoller/hugo-clarity themes/hugo-clarity
cp -a themes/hugo-clarity/exampleSite/* .
% hugo server
ERROR 2022/01/02 17:45:54 Failed to get JSON resource “https://publish.twitter.com/oembed?dnt=false&url=https%3A%2F%2Ftwitter.com%2FSanDiegoZoo%2Fstatus%2F1453110110599868418”: Get “https://publish.twitter.com/oembed?dnt=false&url=https%3A%2F%2Ftwitter.com%2FSanDiegoZoo%2Fstatus%2F1453110110599868418”: net/http: TLS handshake timeout
% grep -r ‘vimeo’ ./
.//config/_default/configTaxo.toml:[privacy.vimeo]
.//content/post/rich-content.md:{{< vimeo_simple 48912912 >}}
常用目录用处如下
子目录名称 | 功能 |
---|---|
archetypes | 新文章默认模板 |
config.toml | Hugo配置文档 |
content | 存放所有Markdown格式的文章 |
layouts | 存放自定义的view,可为空 |
static | 存放图像、CNAME、css、js等资源,发布后该目录下所有资源将处于网页根目录 |
themes | 存放下载的主题 |
% hugo new post/first-hugo-post.md
Content “/Users/xiazemin/source/MyBlogSrc/content/post/first-hugo-post.md” created
使用/docs发布到master branch
第一种方案的好处在于一次push即可将源文档和对应生成的网页文档都发布到Github,操作非常简单。所需要的仅是在config.toml中添加如下一行配置,使得生成的网页默认保存在/docs子目录下:
publishDir = docs
自此运行hugo命令后生成的网页文件将保存在/docs子目录下。将所有文档push到Github的master branch,进入Github对应repository的Settings标签菜单,在GitHub Pages选项的Source栏选择master branch /docs folder
git remote add hugo https://github.com/xiazemin/hugo
git push –set-upstream hugo master
% hugo new about.md
Content “/Users/xiazemin/source/MyBlogSrc/content/about.md” created
% hugo new post/first.md
Content “/Users/xiazemin/source/MyBlogSrc/content/post/first.md” created
hugo server –theme=hugo-clarity –buildDrafts
在站点根目录执行 Hugo 命令生成最终页面:
$ hugo –theme=hugo-clarity –baseUrl=”http://coderzh.github.io/”
https://www.gohugo.org/