ubuntu安装hugo教程
slug
ubuntu-hugo
status
Published
tags
linux
hugo
summary
type
Post
ubuntu安装hugo
安装git
官网 https://git-scm.com/download/linux
sudo apt-get install git
安装go
https://golang.org/dl/ (有可能被墙) 下载go1.17.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gzsudo vim ~/.bashrc
或者
sudo vim /etc/profile
export PATH=$PATH:/usr/local/go/bin保存文件,并且重新加载新的PATH 环境变量到当前的 shell 会话:
source ~/.profile
查看版本
go version下载hugo
https://github.com/gohugoio/hugo/releases
下载 hugo_extended_0.88.1_Linux-64bit.deb
终端输入
sudo dpkg -i hugo_extended_0.88.1_Linux-64bit.deb查看版本
hugo version创建blog
hugo new site blog安装主题
去官网下载主题 https://themes.gohugo.io
我下载的是even https://themes.gohugo.io/hugo-theme-even
再推荐一个主题 https://github.com/uPagge/uBlogger
cd /blog
git clone https://github.com/olOwOlo/hugo-theme-even themes/even在exampleSite目录找到config.toml和content 复制到D:
在blog根目录下,终端输入下面代码
hugo --theme=even --baseUrl="http://waimao365.github.io/" --buildDrafts#even改成你的主题
本地预览
cd /blog
hugo
hugo serverhttp://localhost:1313
建立本地和github仓库的连接
输入github的帐户名和邮箱
git config --global user.name "waimao8"
git config --global user.email "88888@qq.com"查看设置的用户名和密码
git config --list生成 SSH key 与 github 联系
ssh-keygen -t rsa -C “888888@qq.com”一路回车 ubuntu设置显示隐藏文件,在用户目录找到.ssh
打开id_rsa.pub,复制里面的内容。 然后登录github,如果没有就注册一个账号,登录后右上角 头像 -> Settings —> SSH nd GPG keys —> New SSH key。把公钥(id_rsa.pub)粘贴到 key 中,填好 title 并点击 Add SSH key
关联完之后可以在终端输入
ssh git@github.com上传到github
cd到 /public 依次输入
git init
git add .
git commit -m “yyyy/mm/dd-hh:mm”
git remote add origin git@github.com:waimao365/lubutu18.git
git push -u origin master自动部署脚本
https://www.dazhuanlan.com/2019/10/14/5da3e834e0c1d/
https://github.com/coderzh/coderzh-hugo-blog/blob/master/deploy.py
常见错误处理
fatal: 远程 origin 已经存在
此时只需要将远程配置删除,重新添加即可;
git remote rm origin
! [rejected] master -> master (non-fast-forward)
本地生成ReadMe文件
git pull --rebase origin master
git push origin master如果不行,可以强制上传覆盖远程文件(慎用)
git push -f origin master其他
安装typora写文章
https://www.typora.io/#linux
安装Visual Studio Code写文章
https://code.visualstudio.com/
https://code.visualstudio.com/
Visual Studio Code设置中文
打开进入软件,Ctrl + Shift + P,切入到命令行模式。输入“Configure Language”
安装 Notepad++ 编辑主题文件
sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq卸载方法:
sudo apt-get remove notepadqq
sudo add-apt-repository --removeppa:notepadqq-team/notepadqq