Hexo and gitalk

六月 11, 2021 #hexo

Hexo and gitalk

Welcome to Hexo! This is very first post. Check documentation for more info. If get any problems when using Hexo, can find the answer in troubleshooting or asking on GitHub.

Hexo

网上的教程比较丰富, 简单记录一下

安装

sudo npm install -g hexo-cli
cd blog.git && npm install hexo

npm install hexo-theme-icarus
hexo config theme icarus
cat >> _config.yml <<EOF
widgets:
  - type: profile
    position: left
  - type: recent_posts
    position: right
EOF

hexo 找不到主题时会导致打开首页为空白的页面

Quick Start

Create a new post

$ hexo new "My New Post"

More info: Writing

Run server

$ hexo server

More info: Server

Generate static files

$ hexo generate

More info: Generating

Deploy to remote sites

$ hexo deploy

More info: Deployment

Github Pages

git 私有 Repository部署

安装 hexo-deployer-git.

npm config set proxy http://192.168.1.163:10809
npm install hexo-deplyer-git

在 _config.yml添加如下配置:

deploy:
  type: git
  repo: https://github.com/<username>/<project>
  # example, https://github.com/hexojs/hexojs.github.io
  branch: gh-pages

archer主题

在Hexo目录下执行

npm i hexo-generator-json-content --save && npm i --save hexo-wordcount && git clone https://github.com/fi3ework/hexo-theme-archer.git themes/archer --depth=1

修改Hexo目录下的 _config.yml 的 theme 字段为 archer 添加sidebar启用支持: 在Hexo目录下的 _config.yml 中添加以下字段(不是archer下的 _config.yml)

theme: archer
jsonContent:
  meta: true
  pages: false
  posts:
    title: true
    date: true
    path: true
    text: false
    raw: false
    content: false
    slug: false
    updated: false
    comments: false
    link: false
    permalink: true
    excerpt: false
    categories: true
    tags: true

Gitalk

gitalk 配置时本人遇到了部分问题,这里记录下正确运行后的步骤

github setting

生成github的clientID 和 client Secrets
生成位置: Settings > Developer > settings

gitalk config

使用的主题archer 从themes/archer/_config.yml拷贝到hexo项目目录,命名为_config.archer.yml 修改配置: client id 和 client secret为上面github setting生成的内容

   gitalk_client_id: xxx
   gitalk_client_secret: xxxxxx
   gitalk_admin: github_user_name
   gitalk_owner: github_user_name
   gitalk_repo: github_repo
   gitalk_pathname_id: false
   gitalk_create_issue_manually: true

Hexo插入图片

安装插件

npm install hexo-renderer-marked

config.yaml中更改配置如下:

post_asset_folder: true
marked:
prependRoot: true
postAsset: true

使用org文档生成Hexo博客文章

hexo-renderer-org 是 hexo 的一个插件, 用于将 org 文档生成 hexo 的博客文章. Hexo 解析 Markdown 文档的能力保持不变, 相当于给 Hexo 加上 org 文档的支持. npm install https://github.com/mpwang/hexo-renderer-org#master --save

npm install https://github.com/mpwang/hexo-renderer-org#master --save tets

工作原理

安装了 hexo-renderer-org 之后, hexo 命令会使用 emacsclient 去连接 emacs server, 使 用 org export 功能将 org 文档转换成 html, 所以要求 emacs 开启 server 进程.

hexo 的配置

在 hexo 博客的配置文件 _config.yml 中添加

org:
  # 指定 emacs 执行文件路径
  emacs: '/usr/local/bin/emacs'
  # 指定 emacsclient 执行文件路径
  emacsclient: '/usr/local/bin/emacsclient'
  # 是否生成自动注脚, t 为开启, nil 为关闭
  common: |
    #+OPTIONS: html-postamble:nil
  clean_cache: true
  daemonize: true
  # emacs server file 路径, 如果不指定, 以下为默认值
  server_file: "~/.emacs.d/server/server"