配置文件
[[menu.main]] name = “说明” weight = -1 identifier = “sm” url = “/tags/sm”
[[menu.main]] name = “主页” weight = -2 identifier = “blog” url = “/”
[[menu.main]] name = “Java基础” weight = -3 identifier = “jc” url = “/tags/jc”
[[menu.main]] name = “前端” weight = -4 identifier = “qd” url = “/tags/qd”
[[menu.main]] name = “后端” weight = -5 identifier = “hd” url = “/tags/hd”
[[menu.main]] name = “ms” weight = -6 identifier = “ms” url = “/tags/ms”
[[menu.main]] name = “Spring&SpringMVC相关” weight = -7 identifier = “spring” url = “/tags/spring”
[[menu.main]] name = “Mybatis相关” weight = -8 identifier = “mybatis” url = “/tags/mybatis”
[[menu.main]] name = “vue” weight = -9 identifier = “vue” url = “/tags/vue”
[[menu.main]] name = “SpringCloud微服务相关” weight = -10 identifier = “springcloud” url = “/tags/springcloud”
[[menu.main]] name = “异常处理” weight = -11 identifier = “ext” url = “/tags/ext”
[[menu.main]] name = “Freemarker相关” weight = -12 identifier = “freemarker” url = “/tags/freemarker”
[[menu.main]] name = “RabbitMQ相关” weight = -13 identifier = “rabbitmq” url = “/tags/rabbitmq”
[[menu.main]] name = “ElasticSearch相关” weight = -14 identifier = “elasticSearch” url = “/tags/elasticSearch”
[[menu.main]] name = “FastDFS相关” weight = -15 identifier = “fastdfs” url = “/tags/fastdfs”
[[menu.main]] name = “微服务教育网项目” weight = -16 identifier = “xm” url = “/tags/xm”
这些配置是配置文件文件config.toml
主要包含了要写的博客的分类,url表示在菜单栏跳转的路径
- 想要给写的文章分到不同的栏中的话,在新建 例如:
hugo new post/first.md
文件后,在里面的tags内容加上相关上面
identifier
属性中的标签名即可
- 其中 前端:qd 后端:hd Java基础:jc 项目:xm vue:vue
写博客
头部模板
+++ title = "博客书写说明" # 文章标题 date = 2019-07-27T17:02:37+08:00 # 自动添加日期信息 draft = true # 设为false可被编译为HTML,true供本地修改 tags = ["sm"] # 文章标签,可设置多个,用逗号隔开。Hugo会自动生成标签的子URL comments = true # 是否开启Disqus评论功能 share = true # 是否开启分享 +++
在cmd中跳转到G:\hugo\hrblog 项目目录中 执行
hugo new post/XX.md
可创建一个基本模板在模板中注明标题,所属标签等信息
编写可在Typora中编写,在项目目录中执行
hugo server -t casper -D
启动本地服务器测试
项目推到GitHub
创建一个仓库,名字为自己的昵称(全小写) 如
hdorr.github.io
在cmd中
hugo --theme=casper --baseUrl="https://hdorr.github.io/" --buildDrafts
当前目录下会生成public文件
- 进到public,依次执行 1.
git init
2.git add .
3.git commit -m "我的hugo第一次提交"
- 进到public,依次执行 1.
将本地与远端仓库关联
git remote add origin http://github.com/hdorr/hdorr.github.io.git
git push -u origin master
推上去拿
hdorr.github.io
多次编写博客
- 在项目目录上编写了一个
post.sh
脚本文件,包含了上述提交的命令 - 在多次在本地,编写博客之后,双击运行即可自动推送到远端,就能持续更新博客了!!!
博客中插入图片
*由于图片的路径都是相对路径,
第一、在config.toml中配置baseurl。作用是无论在本地还是发布出去,图片的路径都是相对于baseurl而言的。
BaseUrl= "https://hdorr.github.io/"
baseurl= "http://localhost:1313/"
第二、在Markdown图片路径中,以static为根目录写全路径。
示例:假设测试baseurl为http://localhost:1313/,图片位置:/static/img/hugo/123.png,那么在Markdown中写作。这时,在浏览器就可以看到图片了
总结: 1.配置上面两个baseurl 2.插入图片时,将图片保存在static/images下,将路径改为[图片说明](\\static\\xxx.png)
即可显示