start-hugo

start-hugo

Table of Contents

一、start hugo

条件:配置好git,下载hugo,将hugo所在目录放入环境变量

1、创建网站:

hugo new site /path/to/site;

2、克隆主题:

git clone https://github.com/vaga/hugo-theme-m10c.git themes/m10c;(具体方式看主题中的介绍) 主题网址:https://themes.gohugo.io/ 下载主题后进入hugo.toml或config.toml修改theme

3、启动:

hugo server -t m10c --buildDrafts

4、新建文章:

hugo new post/test01.md

5、部署到github:

hugo --theme=m10c --baseURL="https://xxcdu.github.io/" --buildDrafts 生成一个public文件夹

6、进入public后,传入github:

git init
git add .
git commit -m "     "

7、将public远程关联到

github:git remote add origin https://github.com/xxcdu/xxcdu.github.io/

8、将public推上去:

git push -u origin master

9、更新:

生成新的public,git add 、commit推送到github

10、本地启动服务用hugo server -D

git add时提示“warning: LF(换行) will be replaced by CRLF(回车换行)”:
成因:

​ Dos和Windows平台: 使用回车(CR)和换行(LF)两个字符来结束 一行,回车+换行(CR+LF),即“\r\n”;Mac 和 Linux平台:只使用换行(LF)一个字符来结束一行,即“\n”。 ​ 许多 Windows 上的编辑器会悄悄把行尾的换行(LF)字符转换成回车(CR)和换行(LF),或在用户按下 Enter 键时,插入回车(CR)和换行(LF)两个字符。

解决:

​ 提交时转换为LF,检出时转换为CRLF

$ git config --global core.autocrlf true

​ 纯windows:#提交检出均不转换

$ git config --global core.autocrlf false
初次运行git时SSL certificate problem: unable to get local issuer :

certificate错误的成因:当通过HTTPS访问Git远程仓库的时候,如果服务器上的SSL证书未经过第三方机构认证,git就会报错。 解决方法:需关掉sslverify :

	git config --system http.sslverify false #当前用户
	git config --global http.sslverify false #全局用户
	git config http.sslverify false #当前仓库

二、更新hugo

1、在根目录下builddrafts生成public文件夹,例如:

hugo --theme=hugoplate --baseURL="https://xxcdu.github.io/" --buildDrafts

2、进入public文件夹

3、添加到git

git add .

4、提交git

git commit -m "  "

5、push到远程仓库

git push -u origin master

三、hugo常见问题

1、github部署hugo博客后,可能出现文章地址被重定向到localhost的情况,这时需要在仓库中将index.html和index.xml中的文章url改为仓库url,即../post/…..

2、若在github远端修改仓库代码,则在将public push时可能会出现:

error: failed to push some refs to 'https://github.com/xxcdu/xxcdu.github.io/'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

​ 显示远端被修改。这时需要先拉取远程更改:

git pull origin master

​ 在本地分支上更改冲突文件,再git add 提交推送。

3、远程部署后,想在本地启动服务并修改网站文件,使用“hugo server -t m10c –buildDrafts”可能出现本地服务启动后,主页中没有文章链接的情况,这时查看public根目录文件夹的index.html时,发现根本没有与链接文章url有关的的部分。

​ 更新public后,使用“hugo server -D”启动服务后主页出现了文章链接,但点开后跳转到了远程服务器的地址如https://xxcdu.github.io/post/start-hugo/而不是本地文章地址http://localhost:1313/post/hugo-github%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98/,这可能是由于url冲突,需配置好网站根目录下的hugo.toml文件,将baseURL设置为远程部署的地址url。修改后发现已可以在访问本地站点。且注意使用时不要通过

comments powered by Disqus

Related Posts

常见编码特征

常见编码特征

参考文章:30余种加密编码类型的密文特征分析(建议收藏)-腾讯云开发者社区-腾讯云 [TOC] 1、MD5、sha1、HMAC算法、NTLM等相似加密类型: (1)MD5 (例:21232F297A57A5A743894A0E4A801FC3)32位 由数字“0-9”和字母“a-f”所组成的字符串、。如果出现这个范围以外的字符说明这可能是个错误的md5值,没必要再拿去解密。 (2)sha1(例:d033e22ae348aeb5660fc2140aec35850c4da997)40位 (3)相似加密类型长度: # 算法 长度 1 md5 32/16 2 sha1 40 3 sha256 64 4 sha512 128 5 adler32 8 6 crc32 8 7 crc32b 8 8 fnv132 8 9 fnv164 16 10 fnv1a32 8 11 fnv1a64 16 12 gost 64 13 gost-crypto 64 14 haval128,3 32 15 haval128,4 32 16 haval128,5 32 17 haval160,3 40 18 haval160,4 40 19 haval160,5 40 20 haval192,3 48 21 haval192,4 48 22 haval192,5 48 23 haval224,3 56 24 haval224,4 56 25 haval224,5 56 26 haval256,3 64 27 haval256,4 64 28 haval256,5 64 29 joaat 8 30 md2 32 31 md4 32 32 ripemd128 32 33 ripemd160 40 34 ripemd256 64 35 ripemd320 80 36 sha224 56 37 sha3-224 56 38 sha3-256 64 39 sha3-384 96 40 sha3-512 128 41 sha384 96 42 sha512/224 56 43 sha512/256 64 44 snefru 64 45 snefru256 64 46 tiger128,3 32 47 tiger128,4 32 48 tiger160,3 40 49 tiger160,4 40 50 tiger192,3 48 51 tiger192,4 48 52 whirlpool 128 53 mysql 老MYSQL数据库用的,16位,且第1位和第7位必须为0-8 54 mysql5 40 55 NTLM 32 56 Domain Cached Credentials 32 常用解密网站: www.

Read More
docker常用命令

docker常用命令

原文链接:https://blog.csdn.net/Python_0011/article/details/140313812 原文链接:https://blog.csdn.net/Python_paipai/article/details/144389754 [TOC] 1、Docker运行 要在Docker中运行容器,可以使用以下命令: docker run [OPTIONS] IMAGE [COMMAND] [ARG.

Read More
Django基础

Django基础

一、虚拟环境 1、建立虚拟环境 python -m venv xxcdu 2、激活虚拟环境 windows: xxcdu/Scripts/activate linux:

Read More