美文网首页
Hexo + Github 搭建自己的技术博客

Hexo + Github 搭建自己的技术博客

作者: 皇马船长 | 来源:发表于2017-01-16 10:54 被阅读678次

    Hexo 简介

    Hexo 是一个基于nodejs 的静态博客网站生成器,作者是来自台湾的 Tommy Chen 。有以下特点:

    • 不可思议的快速 ─ 只要一眨眼静态文件即生成完成
    • 支持 Markdown
    • 仅需一道指令即可部署到 GitHub PagesHeroku
    • 已移植 Octopress 插件
    • 高扩展性、自订性
    • 兼容于 Windows, Mac & Linux

    使用hexo + github 搭建自己的博客,大概可以分为以下几个步骤

    1. 搭建环境准备(包括node.js和git环境,gitHub账户的配置)
    2. 安装Hexo
    3. 配置Hexo
    4. 怎样将Hexo与github page 联系起来
    5. 怎样发布文章
    6. 主题推荐
    7. 主题Net的简单配置
    8. 添加sitemap和feed插件
    9. 自定义页面,添加分类、关于、404 公益页面等

    hexo 常用命令

    hexo new "postName" #新建文章
    hexo new page "pageName" #新建页面
    hexo generate #生成静态页面至public目录
    hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
    hexo deploy #将.deploy目录部署到GitHub
    
    简写
    hexo n == hexo new
    hexo g == hexo generate
    hexo s == hexo server
    hexo d == hexo deploy
    

    遇到的问题

    • 在浏览器中打开http://localhost:4000/ ,显示无法访问此网站 ,localhost 拒绝了我们的连接请求。 。
      在网上查了下资料,都说是IIS服务器问题 。需要在控制面板中打开 ,
      具体流程是 (以下是win10的):打开控制面板 —— 程序和功能 —— 左侧栏的“启用或关闭Windows功能”,把“Internet Information Services”点上。其中有个FTP服务器可以不开。点确定后就自动安装上了。再打开浏览器,输入localhost就行了
    QQ截图20170113152940.png

    如果还是打不开http://localhost:4000/, 可能是hexo server 的问题 或者 4000端口占用
    我是通过下面这个办法解决的 。
    Hexo 3.0 把服务器独立成了个别模块,您必须先安装 hexo-server 才能使用。

    $ npm install hexo-server --save
    

    安装完成后,输入以下命令以启动服务器,您的网站会在 http://localhost:4000 下启动。在服务器启动期间,Hexo 会监视文件变动并自动更新,您无须重启服务器。

    $ hexo server
    
    • 在执行 hexo new post "article title" 新建一篇博客时 ,报错 can not read a block mapping entry; a multiline key may not be an implicit key at line 72, column 5:

    这个是因为在hexo_config.yml 这个配置文件中 ,字段对应的值 有加空格

    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
    type: git
    repo: git@github.com:***/***.github.io.git
    branch: master
    
    • 执行发布命令时 ,E:\work\hexo>hexo d
    You should configure deployment settings in _config.yml first!
    Available deployer plugins:git
    For more help, you can check the online docs: [http://hexo.io/](http://hexo.io/)
    

    在网上查了大量资料,都说是yml文件格式错了,正确的如下图:

    QQ截图20170116105147.png

    1位置处 是两个空格,2位置处是一个空格,我就是把1位置的两个空格都删了,导致文件发布失败。
    具体参考此文

    参考文档

    Hexo 官网
    手把手教你用Hexo+Github 搭建属于自己的博客
    好用的Markdown编辑器一览
    10款流行的Markdown编辑器,总有一款适合你
    Hexo 部署 Github, Coding 进行国内外分流最全教程
    hexo你的博客
    [github hexo搭建博客出现的错误记录

    相关文章

      网友评论

          本文标题:Hexo + Github 搭建自己的技术博客

          本文链接:https://www.haomeiwen.com/subject/wvksbttx.html