windows下配置hexo+github,hexo设置,markdown语法

来源:互联网 发布:唐宪宗 知乎 编辑:程序博客网 时间:2024/05/22 05:12

官网:https://hexo.io/
preview:https://davidsuperm.github.io/
reference: http://baixin.io/2015/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/
http://www.jianshu.com/p/e99ed60390a8
http://www.tuicool.com/articles/MVzuEr

配置环境


1. 安装node.js: https://nodejs.org/en/
2. 安装git: https://git-scm.com/
3. 安装hexo: $ npm install -g hexo-cli

建立博客目录

  1. $ hexo init <folder> //我的folder名字是blog,后面都用这个名字说明
  2. $ cd <folder>
  3. $ npm install

写博客

注意需要在博客主目录下进行命令行操作

  1. $ hexo new [layout] <title> //新建一个源文件,也可从别的源文件复制
  2. $ hexo g //或者hexo generate 生成静态页面
  3. $ hexo s //或者hexo server 启动服务器,浏览器输入http://localhost:4000访问

配置github

  1. 新建repository,仓库名必须为 your_user_name.github.io
  2. 在blog目录下修改_config.yml文件,注意:后面有空格。

    deploy:type: gitrepository: git@github.com:DavidSuperM/DavidSuperM.github.io.gitbranch: master
  3. $ npm install hexo-deployer-git --save

将本地博客推送到github

注意需要在博客主目录下进行命令行操作

  1. $ hexo clean
  2. $ hexo g //或者hexo generate
  3. $ hexo d //或者hexo deploy

md文件中插入图片

  1. 在blog/source/下创建img文件,将图片放入。
  2. hexo clean, hexo g, hexo d
  3. 在github仓库中找到图片位置,点击download,复制浏览器的链接,即为图片的链接
  4. 我的链接的一般形式为: https://raw.githubusercontent.com/DavidSuperM/DavidSuperM.github.io/master/img/2017-04-16_114626.png

配置博客以及主题

更换主题

  1. 从github下载zip解压到blog/themes中
  2. 修改blog/_config.yml中themes参数,改为下载的文件名

主题链接

  • 知乎https://www.zhihu.com/question/24422335
  • 官方https://hexo.io/themes/

个人喜欢的比较简约清新的主题

  • https://github.com/tufu9441/maupassant-hexo
  • https://github.com/chaooo/hexo-theme-BlueLake
  • http://hmybmny.com/hexo-theme-concise/

自己手动修改配置

  1. blog/_config.yml中per_page参数,表示首页每页显示几条博客
  2. blog/themes/landscape/_config.yml中将# rss: /atom.xml注释掉,rss表示订阅
  3. blog/themes/landscape/_config.yml中show_count: true,表示小工具显示数目(类别)

在博客首页添加友情链接

1.添加数据文文件

在blog/source文件中创建_data目录,在_data目录中新建links.yml文件,内容如下:
github: https://github.com/DavidSuperM
csdn blog: http://blog.csdn.net/davidsuperm

2.添加主题布局文件

在blog/themes/landscape/layout/_widget/添加links.ejs内容如下:

<% if (site.data.links){ %>    <div class="widget-wrap">        <h3 class="widget-title">友情链接</h3>        <div class="widget tag">            <ul class="entry">                <% for (var i in site.data.links){ %>                <li class='link'><a href='<%- site.data.links[i] %>' target="_blank"><%= i %></a></li>            <% } %>            </ul>        </div>    <div><% } %>

3.填写配置文件

在blog/themes/landscape/_config.yml文件中widgets下添加 - links
如下图

添加分类

在blog\source_posts\hello-world.md中添加

---title: hello2date: 2017-04-15 21:47:25categories: androidtags:---

添加readmore

在blog\source_posts\hello-world.md中添加
<!--more-->

markdown语法

注意

  • 所有markdown标志后面要有一个空格
  • 如果标题上一行是列表,则必须在标题和列表之间空一行
    • “`代码注释上下都空一行。(github是没问题,csdn如果不空行界面会不好看)

标题

# 一级标题
## 二级标题
### 三级标题

列表

- 无序列表1
- 无序列表2
- 无序列表3
1. 有序列表1 //注意1.后面有空格
2. 有序列表2
3. 有序列表3

引用

>这个是引用

粗体

**这个是粗体**
*这个是斜体*
***这个是粗体加斜体***

链接和图片

[link text](http://example.com/ “optional title”)
![图片描述](链接)

代码

` `
“` “`

分割线

***

___

markdown文档转为word,pdf

  1. 使用Pandoc https://www.zhihu.com/question/22972843/answer/30096928
  2. 安装Pandoc,使用Typora http://blog.csdn.net/u012814856/article/details/69258511
  3. 使用markdownpad

博客网站绑定域名

待完成。。。

0 0