Leisurely Fool

A leisurely fool float in the ocean


  • Home

  • Tags6

  • Categories5

  • Archives10

  • About

  • Search

Hexo (NexT) Installation and Configuration (The Most Complete)

Posted on 2019-08-13 Edited on 2019-08-20 In Other Learning , Hexo Views: Valine: 1.4k 1 mins.

Installation Process(MacOS)

  1. Create a new repository on Github named {yourname}.github.io. The {yourname} must be the same as your Github username.

  2. Install hexo (node and git need to be installed previously)

    npm install -g hexo-cli

  3. Create local blog folder

    hexo init myBlog
    cd myBlog
    npm install

  4. Install hexo developer git

    npm install hexo-deployer-git --save

  5. Create new blog

    hexo new "My New Post"

  6. Start local server

    hexo s

  7. So far you can open the browser and go to localhost:4000, then you will see the Hello World page

  8. Add github push configuration to hexo _config.yml (there is space between key and value, BE CAREFUL)

    1
    2
    3
    4
    deploy:
    type: git
    repo: https://github.com/{yourname}/{yourname}.github.io.git
    branch: master
  9. Clean the public folder to avoid cache

    hexo clean

  10. Push to github (g stands for generate the needed files in public folder)

    hexo g -d

  11. Go to {yourname}.github.io and you will see the succeful online page

Configuration

Image Uploader

Prepare an online image uploader like Picgo, and follow the instructions

Jupyter Code Block Support

Embed Local File

  1. npm install hexo-jupyter-notebook –save`

  2. brew install pandoc

  3. pip install nbconvert

  4. Update _config.yml in hexo folder –> post_asset_folder: true

  5. Create new folder named jupyter under folder _post to save the ipynb code blocks

    mkdir jupyter-demo

  6. Add the following code to your target md file

  1. If you want to change the height and width of the iframe, please go to node_module of hexo, and find main.py in hexo-jupyter-notebook , change the relative configuration.

    1
    2
    3
    <iframe id='ipynb' marginheight="0" frameborder="0" width='924px' 
    height='680px' srcdoc="%s" style="scrolling:yes;">
    </iframe>

Embed Online File

  1. Go to https://nbviewer.jupyter.org/ and paste the link of online jupyter notebook, like

    https://github.com/kinglin/YTClip/blob/cliptrial/02_Code/01_Scripts/FrameSampling.ipynb

  2. Use the following code block and input the generated URL by nbviewer:

    https://nbviewer.jupyter.org/github/kinglin/YTClip/blob/master/02_Code/01_Scripts/rename_addprefix.ipynb

1
<iframe src="your_URL" width="700" height="500"></iframe>
## Change Theme
  1. Themes repository

  2. Go to the root folder of your blog

    git clone https://github.com/theme-next/hexo-theme-next themes/next

  3. Update _config.yml in hexo folder –> theme: next

Add Space between Chinese character and English words Automately

npm install hexo-filter-auto-spacing --save

Then you can find the denpendency in package.json :"hexo-filter-auto-spacing": "^0.2.1"

Add Search Feature

npm install hexo-generator-searchdb --save

Update _config.yml in hexo folder

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

Update _config.yml in NexT folder

1
2
local_search:
enable: true

Attach Custom Domain

  1. Buy one at aliyun.com or godaddy.com or any websites that provide the services.

  2. Take aliyun.com as example, we need to resolve the domain and add 2 records.

  3. Go to your github page settings and attach the customized domain.

  4. Go to hexo source folder and add a new file named CNAME, fill in the domain. (To avoid being wiped out when submit changes to github)

Add Feedback (Valine)

  1. Update _config.yml in theme next –> enable valine

  2. Login or register on LeanCloud, then replace the appid and appkey to _config.yml

Add Word Count & Estimate Reading Time

  1. npm install hexo-symbols-count-time --save

  2. Add following code block to hexo _config.yml

    1
    2
    3
    4
    symbols: true
    time: true
    total_symbols: true
    total_time: true
  3. Enable field symbols_count_time in NexT _config.yml

Change URI to Permanent Link

As we know, the original link of our posts is composited by year, month, day and title, but this location is not friendly enough to SEO, so that we need to change it to the permanent way.

  1. npm install hexo-abbrlink --save

  2. Update hexo _config.yml

    1
    2
    3
    4
    permalink: posts/:abbrlink.html
    abbrlink:
    alg: crc32 # 算法:crc16(default) and crc32
    rep: hex # 进制:dec(default) and hex
  3. Restart hexo and we will find the link of our post will be like localhost:4000/posts/12345.html

Add Google Analytics

  1. Register on Google Analytics

  2. Apply a new account for your website and you will get an tracking_id like UA-14xxxx949-1

  3. Update NexT _config.yml

    1
    2
    3
    google_analytics:
    tracking_id: UA-14xxxx949-1
    localhost_ignored: true

Add SEO Related

Add Sitemap

  1. npm install hexo-generator-sitemap --save

  2. Add following config in hexo _config.yml:

    1
    2
    sitemap:  
    path: sitemap.xml
  3. change URL to your own domain

Add robot.txt

  1. Create a new file named robot.txt under the folder hexo source, and fill in the following text.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    User-agent: *
    Allow: /
    Allow: /archives/

    Disallow: /vendors/
    Disallow: /js/
    Disallow: /css/
    Disallow: /fonts/
    Disallow: /vendors/
    Disallow: /fancybox/

    Sitemap: https://pojian.xyz/sitemap.xml
    Sitemap: https://pojian.xyz/baidusitemap.xml
  2. hexo clean

  3. hexo g -d

  4. Add sitemap to Google Search Console

Block Testing

Code Block

1
print("helloworld")

This is the explaination of the code block.

Test Image Upload

Test Jupyter Code Block

Test Video Embedded

## Test Formula

This doesn’t work $$\frac{1}{1+\frac{1}{2}}$$ (TODO)

Transform formula to image on https://www.codecogs.com/latex/eqneditor.php?lang=zh-cn

Reference

https://segmentfault.com/a/1190000017986794

http://huanyouchen.github.io/2018/05/30/hexo-support-jupyter-notebook-in-blog/

https://hexo.io/zh-cn/docs/

https://github.com/Molunerfinn/PicGo

https://www.jianshu.com/p/191d1e21f7ed

https://fontawesome.com/v4.7.0/icons/

https://valine.js.org/hexo.html#hexo-theme-raytaylorism

https://www.iconfont.cn/

https://blog.csdn.net/weixin_43971764/article/details/96754325

https://juejin.im/post/5c38b63f6fb9a04a0a5f68b3

http://chitanda.me/2015/11/03/multiple-git-pages-in-one-github-account/

  • Post author: Lin Ce
  • Post link: https://leisurelyfool.com/posts/19796.html
  • Copyright Notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally.
hexo markdown Github
Tweet
Share
Link
Send
Send
Build Personal Blog -- Github Page + Hexo Installation
  • Table of Contents
  • Overview
Lin Ce

Lin Ce

Major in Application of ML and DL
10 posts
5 categories
6 tags
GitHub E-Mail
  1. 1. Installation Process(MacOS)
  2. 2. Configuration
    1. 2.1. Image Uploader
    2. 2.2. Jupyter Code Block Support
      1. 2.2.1. Embed Local File
      2. 2.2.2. Embed Online File
    3. 2.3. Add Space between Chinese character and English words Automately
    4. 2.4. Add Search Feature
    5. 2.5. Attach Custom Domain
    6. 2.6. Add Feedback (Valine)
    7. 2.7. Add Word Count & Estimate Reading Time
    8. 2.8. Change URI to Permanent Link
    9. 2.9. Add Google Analytics
    10. 2.10. Add SEO Related
      1. 2.10.1. Add Sitemap
      2. 2.10.2. Add robot.txt
  3. 3. Block Testing
    1. 3.1. Code Block
    2. 3.2. Test Image Upload
    3. 3.3. Test Jupyter Code Block
    4. 3.4. Test Video Embedded
  4. 4. Reference
© 2019 Lin Ce | 9k | 8 mins.
|
0%