hexo博客搭建


基础搭建

Hexo

选一个博客框架,hexo是静态网站框架,基于nodejs,可以生成静态网页,部署到github上。 需要提前安装gitnodejs。 - check git version: git --version - check nodejs version: node -v - check npm version: npm -v 安装 cnmp (optional) - npm install -g cnpm --registry=https://registry.npm.taobao.org - check cnmp version: cnpm -v

安装 hexo-cli - cnpm install -g hexo-cli - check hexo version: hexo -v

初始化blog目录

  • mkdir blog | cd blog
  • sudo hexo init # clone hexo-starter repo
  • hexo s # start blog, default port 4000

添加博客

  • hexo n "newblog" # add new blog, save in /source/_posts
    • edit blog in /source/_posts/newblog.md
  • hexo clean # clean cache
  • hexo g # generate static files
  • hexo s # start blog, default port 4000

github部署

  • build blog address:
    • add new token in github
    • github new repo: https://.github.io/
  • cnpm install hexo-deployer-git --save
    deploy:
        type: git
        repo: https://<token>@github.com/<username>/<username>.github.io.git
        branch: master
  • hexo d # deploy blog

主题

安装

  • theme 推荐:
    • https://github.com/litten/hexo-theme-yilia.git
    • https://github.com/theme-next/hexo-theme-next.git
  • clone theme into themes folder, e.g. git clone https://github.com/theme-next/hexo-theme-next.git themes/next
  • edit _config.yml, set theme to next
    theme: next
  • hexo c&&hexo g&&hexo d # clean cache, generate static files, deploy blog

配置主题

大部分配置在_config.yml 文件中,可以参考官方文档 #### 基础 ##### scheme - Scheme 是 NexT 提供的一种特性,借助于 Scheme,NexT 为你提供多种不同的外观。同时,几乎所有的配置都可以 在 Scheme 之间共用。 - muse - 默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白 - Mist - Muse 的紧凑版本,整洁有序的单栏外观 - Pisces - 双栏 Scheme,小家碧玉似的清新 Scheme 的切换通过更改 _config.yml 文件,搜索 scheme 关键字。 你会看到有三行 scheme 的配置,将你需用启用的 scheme 前面注释 # 去除即可。 ##### language ##### menu 菜单配置包括三个部分,第一是菜单项(名称和链接),第二是菜单项的显示文本,第三是菜单项对应的图标。 NexT 使用的是 Font Awesome 提供的图标,可以在 Font Awesome 查看。

menu:
  home: / || home
  archives: /archives || archive
  tags: /tags || tags
  categories: /categories || th
#### 其他 主题美化是个逐渐积累的过程, 后期可以在相册、挂件、评论、搜索、sitemap、rss等方面进行配置。 一些工具插件: gallery page--justified gallery


文章作者: 庞贝堡垒
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 庞贝堡垒 !
评论
  目录