一些常用的Hugo命令与Markdown语法
生成一篇文档
Hugo博客常用功能与命令
生成一篇文档
hugo new post/XXXX.md
待本地启动后,可以继续修改这篇文档的内容,在需要的文件夹中加入需要的图片,然后调整相关的参数,看看图片的几个功能是否正常或者符合预期。
更多的配置参数可以阅读tranquilpeak主题的使用文档。
启动博客的本地预览
建议在配置文件中设置好主题,或者使用 –t指令指定主题,在站点的根目录下使用命令进行本地启动,本地启动的命令如下:
hugo server -D
如果执行顺利,会有如下提示:
在浏览器中输入图片红框中的地址进行预览效果,比如一般是localhost:1313。
生成静态文件
接下来是生成静态文件,这里要把配置文件config.toml中的baseUrl修改为自己的仓库地址,即https://XXXXXXXX.github.io/ 或者在hugo命令中使用指令指定 –baseUrl=“https://XXXXXXXX.github.io/”
如果在配文件中已经设置好baseUrl和themes的路径,以及输出文件夹,可以直接在站点根目录下采用以下命令:
hugo
成功后会按照设置好的路径生成一个public文件夹,接下来我们需要将public文件夹中的内容提交到Github的仓库中去。
接下去的内容就不详细讲述了
markdown语法
另外附上一些常用markdown语法,多用才能记住
Emphasis
*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__
_You **can** combine them_
This text will be italic This will also be italic
This text will be bold This will also be bold
You can combine them
Lists
* Item 1
* Item 2
* Item 2a
* Item 2b
1. Item 1
1. Item 2
1. Item 3
1. Item 3a
1. Item 3b
-
Item 1
-
Item 2
- Item 2a
- Item 2b
- Item 1
- Item 2
- Item 3
- Item 3a
- Item 3b
Images

Format: 
Format:
Links
http://github.com - automatic!
[GitHub](http://github.com)
http://github.com - automatic! GitHub
Blockquotes
As Kanye West said:
> We're living the future so
> the present is our past.
As Kanye West said:
We’re living the future so the present is our past.
Inline code
I think you should use an
`<addr>` element here instead.
I think you should use an
<addr>
element here instead.
Syntax highlighting
Here’s an example of how you can use syntax highlighting with GitHub Flavored Markdown:
```javascript
function fancyAlert(arg) {
if(arg) {
$.facebox({div:'#foo'})
}
}
```
function fancyAlert(arg) {
if(arg) {
$.facebox({div:'#foo'})
}
}
You can also simply indent your code by four spaces:
function fancyAlert(arg) {
if(arg) {
$.facebox({div:'#foo'})
}
}
Table
First Header | Second Header
------------ | -------------
Content from cell 1 | Content from cell 2
Content in the first column | Content in the second column
First Header | Second Header |
---|---|
Content from cell 1 | Content from cell 2 |
Content in the first column | Content in the second column |