1.安装hugo

brew install hugo

2.创建site

hugo new site blog

3.安装主题

cd blog
git init
git submoudule add https://github.com/panr/hugo-theme-hello-friend.git themes/hello-friend

3.修改hugo.toml配置

# 网站地址
baseURL = 'https://jemhunter.com/'
# 网站语言
languageCode = 'zh-CN'
# 网站名称
title = "贝海拾珠者"
# 作者
author = 'Dinovich'
# 主题
theme = "hello-friend"
# 版权
copyright = 'Dinovich'
# 是否允许emoji
enableEmoji = true
# Google分析
googleAnalytics = 'G-3333'
# 
enableRobotsTXT = true
hasCJKLanguage = true
# disqus评论
disqusShortname = ''
defaultContentLanguage = 'zh'


[params]
  title = '贝海拾珠者'
  # dir name of your blog content (default is `content/posts`).
  # the list of set content will show up on your index page (baseurl).
  contentTypeName = "posts"
  # OS theme is default when not provided, but you can force it to "light" or "dark"
  defaultTheme = "light"
  # if you set this to 0, only submenu trigger will be visible
  showMenuItems = 4
  # Show reading time in minutes for posts
  showReadingTime = true
  # Show table of contents at the top of your posts (defaults to false)
  # Alternatively, add this param to post front matter for specific posts
  # toc = true
  # Show full page content in RSS feed items
  #(default is Description or Summary metadata in the front matter)
  # rssFullText = true

# Hugo 解析文档的配置
[markup]
  # 语法高亮设置 (https://gohugo.io/content-management/syntax-highlighting)
  [markup.highlight]
    # false 是必要的设置 (https://github.com/dillonzq/LoveIt/issues/158)
    noClasses = false

[languages]
  [languages.zh]
    [languages.zh.params.logo]
      logoText = "贝海拾珠者"
      logoHomeLink = "/"

# 菜单配置
[menu]
  [[menu.main]]
    weight = 1
    identifier = "posts"
    # 你可以在名称 (允许 HTML 格式) 之前添加其他信息, 例如图标
    pre = ""
    # 你可以在名称 (允许 HTML 格式) 之后添加其他信息, 例如图标
    post = ""
    name = "文章"
    url = "/posts/"
    # 当你将鼠标悬停在此菜单链接上时, 将显示的标题
    title = ""
  [[menu.main]]
    weight = 2
    identifier = "tags"
    pre = ""
    post = ""
    name = "标签"
    url = "/tags/"
    title = ""
  [[menu.main]]
    weight = 3
    identifier = "categories"
    pre = ""
    post = ""
    name = "分类"
    url = "/categories/"
    title = ""
  [[menu.main]]
    weight = 3
    identifier = "about"
    pre = ""
    post = ""
    name = "关于"
    url = "/about/"
    title = ""

4. 创建.gitignore

.DS_Store
/public
/resources
.hugo_build.lock

5. github创建私有仓库,将blog推送到远程仓库

6. 注册域名

随便在哪个域名注册网站注册一个域名

7. cloudflare关联github账户

在cloudflare中page中关联github账户,并且创建一个page,选刚创建的仓库,在部署的框架选择hugo,然后就可以部署了

8. 关联域名

在刚刚创建的page项目中,关联自己买的域名,需要设置cname, 等一切都生效后网站就OK

9. 配置webhook

在page项目生成一个webhook地址,然后配置到github仓库上。

10. 总结

  • 文章的源码由github托管,不需要又要托管文章源码,还要托管部署源码
  • cloudflare配置webhook一劳永逸

相关链接