Hugo Jane 主题建站笔记
保留来源中的 Jane 主题、历史命令与评论系统配置,未验证当前 Hugo 版本兼容性。
hugo 使用
hugo new site [项目名]创建项目
创建文章
hugo new about.md
创建目录文章
hugo new post/first.md·
运行调试
shell
hugo server --theme=jane --buildDrafts
hugo server --theme=jane --buildDrafts -bind=0.0.0.0 --port=8087
hugo server --theme=jane --buildDrafts --port=8087打包部署
shell
# GitHub 历史目标
hugo --theme=jane --baseUrl="https://docs.example.com/"
# Gitee 历史目标
hugo --theme=jane --baseURL="https://docs.example.com/blog"
# 本地域名历史目标
hugo --theme=jane --baseURL="http://blog.localhost"添加文章
text
+++
title = "Doker 安装"
tags = [ "Syetem" ]
date = 2019-01-26T12:48:54+08:00
draft= false
categories = [ "utils" ]
series = [ "docker" ]
description = "docerk linux 安装 " # 备注
project_url = ""
+++文章显示调试 和时间
layouts/index.html
<div class="post">
<h1 class="post-title">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
</h1>
<span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
{{ .Content }}
// Description
<span class="post-date">{{ .Date.Format "2006-01-02 15:04:05" }}</span>
</div>静态部署
hugo --theme=jane --baseUrl="https://docs.example.com/"
会自动生成到根目录下
public将public上传至git使用 nginx 静态部署
设置菜单
[[menu.main]]
name = "Golang"
pre = "<i class='fa fa-heart'></i>"
weight = -110
identifier = "golang"
url = "/golang/"
[[menu.main]]
name = "Java"
pre = "<i class='fa fa-road'></i>"
weight = 12
identifier = "java"
url = "/java/"
[[menu.main]]
name = "Python"
identifier = "python"
pre = "<i class='fa fa-road'></i>"
weight = 12
url = "/python/"第二种
<h6 class="sitetaglisttitle">Tags</h6>
<ul class="sitetaglist">
{{ range first 10 .Site.Taxonomies.tags.ByCount }}
{{ if ge .Count 1 }}
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }} ({{ .Count }})</a></li>
{{ end }}
{{ end }}
</ul>目录
text
▸ archetypes/ #包括内容类型,在创建新内容时自动生成内容的配置
▸ content/ # 网站内容,全部使用markdown格式
▸ layouts/ # 网站模板文件,决定内容如何呈现
▸ static/ # 图片、css、js 等静态资源
▸ themes/ # 存放主题
config.toml # 是网站的主配置文件参数介绍
text
--bind="127.0.0.1" 服务监听IP地址;
-p, --port=1313 服务监听端口;
-w, --watch[=true] 监听站点目录,发现文件变更自动编译;
-D, --buildDrafts 包括被标记为draft的文章;
-E, --buildExpired 包括已过期的文章;
-F, --buildFuture 包括将在未来发布的文章;
-b, --baseURL="www.datals.com" 服务监听域名;
--log[=false]: 开启日志;
--logFile="/var/log/hugo.log": log输出路径;
-t, --theme="" 指定主题;
-v, --verbose[=false]: 输出详细信息使用
hugo server -t hyde --buildDrafts --baseURL=http://www.datals.com --bind=0.0.0.0 --port=80 -w
md 使用对应的标签
[来源图片缺失:image-20200229113106886]
1.2
yaml
---
# 常用定义
title: 'An Example Post' # 标题
date: 2018-01-01T16:01:23+08:00 # 创建时间
lastmod: 2018-01-02T16:01:23+08:00 # 最后修改时间
draft: false # 是否是草稿?
tags: [ 'tag-1', 'tag-2', 'tag-3' ] # 标签
categories: [ 'index' ] # 分类
author: 'xianmin' # 作者
# 用户自定义
# 你可以选择 关闭(false) 或者 打开(true) 以下选项
comment: false # 关闭评论
toc: false # 关闭文章目录
# 你同样可以自定义文章的版权规则
contentCopyright: '<a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">CC BY-NC-ND 4.0</a>'
reward: false # 关闭打赏
mathjax: true # 打开 mathjax
---FQA
开发启动方式
- hugo server --theme=jane --disableFastRender -bind=0.0.0.0 --port=8087
- hugo server --theme=jane --disableFastRender
- hugo server --theme=jane --port=8087
留言系统不能用
登录后台(https://console.leancloud.cn/apps),错误码 504 和 403
- 检查密钥是否正确
- 设置-应用 Keys
- 检查配置是否正确
- 检查是否服务是否未激活
- 登录网站首页 CcBlog 应用是否激活
- 设置白名单
- 设置-安全中心-web 安全域名
继续阅读
- 静态站点与文档站完整实践与解答
- 静态站点与文档站上手与对象
- 静态站点与文档站任务与配置Jekyll 目录与文章模板 · 历史版本