zoukankan      html  css  js  c++  java
  • Hexo博客系列(二)-在多台机器上利用Hexo发布博客

    【原文链接】:https://blog.tecchen.xyz ,博文同步发布到博客园。
    由于精力有限,对文章的更新可能不能及时同步,请点击上面的原文链接访问最新内容。
    欢迎访问我的个人网站:https://www.tecchen.xyz

    针对在公司及家里的电脑上都有编辑发布博客的可能,或者多人同时维护一个博客的情况,需要在多台机器上配置环境好环境,然后将Git仓库中的博客更新下来,继续编辑发布博客。
    个人是将博客托管在Gitee(码云)的仓库,将NexT主题托管在Github上的仓库。
    因为博客源码需要放在私有仓库(Github也已经开发私有仓库了,Gitlab本来就支持私有仓库),不开放出来,NexT主题是直接fork的NexT官方主题(https://github.com/theme-next/hexo-theme-next/ ),根据自己的需要进行修改保存。
    下面介绍已有博客仓库和主题仓库的情况下,如何在各台机器进行配置。

    日常写博客

    正常情况下,仅仅需要到博客根路径和主题根路径,使用git pull拉取最新代码。

    • 第一步:clone自己的hexo博客项目
      在想要新建的目录下(例如:D:IdeaProjects)执行以下命令,创建目录hexo-blog并clone项目。
    git clone git@gitlab.com:java4candy/hexo-blog.git hexo-blog
    
    
    • 第二步:clone自己的next主题项目
      在想要新建的目录下(例如:D:IdeaProjects)执行以下命令,创建目录hexo-blog/themes/next并clone Next主题代码。
    git clone git@gitlab.com:java4candy/hexo-theme-next.git hexo-blog/themes/next
    
    • 第三步:启动服务器
    hexo clean && hexo generate && hexo server
    
    • 第四步:使用浏览器进行访问
      访问http://localhost:4000/ 即可。

    初始化环境

    以下仅限在新机器上进行一次性操作。

    • 第一步:clone自己的hexo博客项目
    git clone git@gitlab.com:java4candy/hexo-blog.git hexo-blog
    
    
    • 第二步:clone自己的next主题项目
    git clone git@gitlab.com:java4candy/hexo-theme-next.git hexo-blog/themes/next
    
    • 第三步:安装hexo
      使用淘宝镜像,安装依赖
    npm install --save --registry=https://registry.npm.taobao.org
    

    该命令会根据package.json中的dependencies将依赖下载并安装到node_modules目录。
    可以使用npm ls -dept 0查看具体有哪些依赖。

    +-- hexo@3.8.0
    +-- hexo-asset-image@0.0.3
    +-- hexo-deployer-git@0.3.1
    +-- hexo-generator-archive@0.1.5
    +-- hexo-generator-baidu-sitemap@0.1.6
    +-- hexo-generator-category@0.1.3
    +-- hexo-generator-index-pin-top@0.2.2
    +-- hexo-generator-sitemap@1.2.0
    +-- hexo-generator-tag@0.2.0
    +-- hexo-renderer-ejs@0.3.1
    +-- hexo-renderer-marked@0.3.2
    +-- hexo-renderer-stylus@0.3.3
    +-- hexo-server@0.3.3
    `-- hexo-symbols-count-time@0.4.4
    

    【不要执行hexo init,其实执行后,也会提示文件夹不为空。】

    FATAL D:IdeaProjectshexo-blog not empty, please run `hexo init` on an empty folder and then copy your files into it
    FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
    Error: target not empty
    
    • 第四步:启动服务器
      使用hexo server或者简写hexo s启动服务器
    hexo clean && hexo generate && hexo server
    
    • 第五步:使用浏览器进行访问
      访问http://localhost:4000/ 即可。
  • 相关阅读:
    自定义组件要加@click方法
    绑定样式
    647. Palindromic Substrings
    215. Kth Largest Element in an Array
    448. Find All Numbers Disappeared in an Array
    287. Find the Duplicate Number
    283. Move Zeroes
    234. Palindrome Linked List
    202. Happy Number
    217. Contains Duplicate
  • 原文地址:https://www.cnblogs.com/Candies/p/10246135.html
Copyright © 2011-2022 走看看