# note_blogs_hexo **Repository Path**: panda_code_note/note_blogs_hexo ## Basic Information - **Project Name**: note_blogs_hexo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-22 - **Last Updated**: 2023-06-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 第一章 Hexo基本环境 ## 1.1 必备的软件环境 1. Git:需要在Github部署博客系统 2. 新建Github账户,并新建仓库:**固定名称【账户名称.github.io】** 3. Node:下载、安装、调试博客系统 4. Typora:编写文章的文本编辑器 ## 1.2 初始化 1. 安装Hexo:在命令行用npm安装 ```sh npm install -g hexo-cli # 或者 cnpm install -g hexo-cli ``` 2. 新建博客站点目录,并初始化 ```sh hexo init ``` 3. 进入目录并使用npm初始化站点 ```sh npm install # 或者 cnpm install ``` ## 1.3 hexo博客目录说明 | 目录 | 作用 | | ------------ | --------------------- | | node_modules | 当前站点的依赖包 | | public | 存放生成的页面 | | scaffolds | 生成文章的一些模板 | | source | 用来存放你的文章 | | themes | 主题 | | _config.yml | 博客的配置文件 | | package.json | npm安装的依赖配置文件 | ## 1.4 安装Hexo必须依赖 ### 1. 搜索 - 搜索依赖 ```sh npm install hexo-generator-searchdb --save ``` - 配置_config.yml ```yml # 生成的搜索的索引文件 search: path: search.xml field: post format: html ``` ### 2. RSS订阅 - 下载依赖 ```sh npm install hexo-generator-feed ``` - 添加配置_config.yml ```yml # Extensions plugins: hexo-generator-feed #Feed Atom feed: type: atom path: atom.xml limit: 20 ``` ```yml feed: type: atom path: atom.xml limit: 20 hub: content: content_limit: 140 content_limit_delim: ' ' order_by: -date ``` ### 3. Git - 下载依赖 ```sh npm install hexo-deployer-git ``` - 配置_config.yml ```yml deploy: type: "git" repo: git@github.com:xiaoliuxuesheng/xiaoliuxuesheng.github.io.git branch: master ``` ## 1.5 Hexo命令行 ### 1. hexo init ```sh hexo init [folder] ``` > - 命令用于初始化本地文件夹为网站的根目录 > - folder 可选参数,用以指定初始化目录的路径,若无指定则默认为当前目录 ### 2. hexo new - 新建正式文章 ```sh hexo new [layout] ``` > - `layout` 可选参数,用以指定文章类型,若无指定则默认由配置文件中的 default_layout 选项决定 > - `title` 必填参数,用以指定文章标题,如果参数值中含有空格,则需要使用双引号包围 - 新建草稿文件:会在source/_drafts目录下生成一个new-draft.md文件 ```sh hexo new draft "new draft" # 如下方式启动server: hexo server --drafts ``` - 把草稿变成文章,或者页面 ```sh hexo publish [layout] <filename> ``` ### 3. hexo generate ```sh hexo generate ``` > - 命令用于生成静态文件,一般可以简写为 `hexo g` > - `-d` 选项,指定生成后部署,与 `hexo d -g` 等价 ### 4. hexo server ```sh hexo server [选项] # 运行服务器前需要安装 hexo-server 插件 npm install hexo-server --save ``` > - 用于启动本地服务器,一般可以简写为 `hexo s`, > - `-p` 选项,指定服务器端口,默认为 4000 > - `-i` 选项,指定服务器 IP 地址,默认为 0.0.0.0 > - `-s` 选项,静态模式 ,仅提供 public 文件夹中的文件并禁用文件监视 ### 5. hexo deploy ```sh hexo deploy ``` > - 用于部署网站,一般可以简写为 `hexo d` > - 部署前需要修改 _config.yml 配置文件,下面以 git 为例进行说明 > > ```yaml > deploy: > type: git > repo: <repository url> > branch: master > message: 自定义提交消息,默认为Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} > ``` ### 6. hexo clean ```sh hexo clean ``` > - 用于清理缓存文件,是一个比较常用的命令 Hexo博客搭建之引用站内文章 RebeccaYan 2017.07.04 19:27:54 字数 53 阅读 607 在写文章的过程中,有时候需要引用站内的其他文章。可以通过内置的标签插件的语法post_link来实现引用。 {% post_link 文章文件名(不要后缀) 文章标题(可选) %} 举例 引用 Hello.md {% post_link Hello %} 或者 {% post_link Hello 你好 %} # 第二章 Hexo主题 # 第三章 Hexo高级设置 <iframe id="B-Video" src="//player.bilibili.com/player.html?aid=811550159&bvid=BV1m34y1h76K&cid=718963215&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" width="100%" height="450"> </iframe>