hexo 常用命令
hexo
npm install hexo -g #安装 npm update hexo -g #升级 hexo init #初始化
简写
hexo n "我的博客" == hexo new "我的博客" #新建文章 hexo p == hexo publish hexo g == hexo generate#生成 hexo s == hexo server #启动服务预览 hexo d == hexo deploy#部署
服务器
hexo server #Hexo 会监视文件变动并自动更新,您无须重启服务器。 hexo server -s #静态模式 hexo server -p 5000 #更改端口 hexo server -i 192.168.1.1 #自定义 IP hexo clean #清除缓存 网页正常情况下可以忽略此条命令 hexo g #生成静态网页 hexo d #开始部署
监视文件变动
hexo generate #使用 Hexo 生成静态文件快速而且简单 hexo generate --watch #监视文件变动
完成后部署
两个命令的作用是相同的
hexo generate --deploy
hexo deploy --generate
hexo deploy -g hexo server -g
草稿
hexo publish [layout]</pre> <h2 id="articleHeader6"><span style="font-size: 12px; font-family: 宋体">模版</span></h2> <pre class="brush:html;gutter:true;">hexo new "postName" #新建文章 hexo new page "pageName" #新建页面 hexo generate #生成静态页面至public目录 hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server) hexo deploy #将.deploy目录部署到GitHub hexo new [layout] <title> hexo new photo "My Gallery" hexo new "Hello World" --lang tw</pre> <table> <thead> <tr><th><span style="font-size: 12px; font-family: 宋体">变量</span></th><th><span style="font-size: 12px; font-family: 宋体">描述</span></th></tr> </thead> <tbody> <tr> <td><span style="font-size: 12px; font-family: 宋体">layout</span></td> <td><span style="font-size: 12px; font-family: 宋体">布局</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">title</span></td> <td><span style="font-size: 12px; font-family: 宋体">标题</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">date</span></td> <td><span style="font-size: 12px; font-family: 宋体">文件建立日期</span></td> </tr> </tbody> </table> <pre class="hljs subunit"></pre> <pre class="brush:html;gutter:true;">title: 使用Hexo搭建个人博客 layout: post date: 2014-03-03 19:07:43 comments: true categories: Blog tags: [Hexo] keywords: Hexo, Blog description: 生命在于折腾,又把博客折腾到Hexo了。给Hexo点赞。</pre> <h2 id="articleHeader7"><span style="font-size: 12px; font-family: 宋体">模版(Scaffold)</span></h2> <pre class="brush:html;gutter:true;">hexo new photo "My Gallery"</pre> <table> <thead> <tr><th><span style="font-size: 12px; font-family: 宋体">变量</span></th><th><span style="font-size: 12px; font-family: 宋体">描述</span></th></tr> </thead> <tbody> <tr> <td><span style="font-size: 12px; font-family: 宋体">layout</span></td> <td><span style="font-size: 12px; font-family: 宋体">布局</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">title</span></td> <td><span style="font-size: 12px; font-family: 宋体">标题</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">date</span></td> <td><span style="font-size: 12px; font-family: 宋体">文件建立日期</span></td> </tr> </tbody> </table> <h2 id="articleHeader8"><span style="font-size: 12px; font-family: 宋体">设置文章摘要</span></h2> <pre class="hljs xml"><span style="font-size: 12px; font-family: 宋体"><code>以上是文章摘要 <span class="hljs-comment"><!--more--> 以下是余下全文 </span></code></span></pre> <h2 id="articleHeader9"><span style="font-size: 12px; font-family: 宋体">写作</span></h2> <pre class="brush:html;gutter:true;">hexo new page <title> hexo new post <title></pre> <table> <thead> <tr><th><span style="font-size: 12px; font-family: 宋体">变量</span></th><th><span style="font-size: 12px; font-family: 宋体">描述</span></th></tr> </thead> <tbody> <tr> <td><span style="font-size: 12px; font-family: 宋体">:title</span></td> <td><span style="font-size: 12px; font-family: 宋体">标题</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">:year</span></td> <td><span style="font-size: 12px; font-family: 宋体">建立的年份(4 位数)</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">:month</span></td> <td><span style="font-size: 12px; font-family: 宋体">建立的月份(2 位数)</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">:i_month</span></td> <td><span style="font-size: 12px; font-family: 宋体">建立的月份(去掉开头的零)</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">:day</span></td> <td><span style="font-size: 12px; font-family: 宋体">建立的日期(2 位数)</span></td> </tr> <tr> <td><span style="font-size: 12px; font-family: 宋体">:i_day</span></td> <td><span style="font-size: 12px; font-family: 宋体">建立的日期(去掉开头的零)</span></td> </tr> </tbody> </table> <h3 id="articleHeader10"><span style="font-size: 12px; font-family: 宋体">推送到服务器上</span></h3> <pre class="brush:html;gutter:true;">hexo n #写文章 hexo g #生成 hexo d #部署 #可与hexo g合并为 hexo d -g</pre> <h2 id="articleHeader11"><span style="font-size: 12px; font-family: 宋体">报错</span></h2> <h3 id="articleHeader12"><span style="font-size: 12px; font-family: 宋体">1.找不到git部署</span></h3> <pre class="hljs subunit"></pre> <pre class="brush:html;gutter:true;">ERROR Deployer not found: git</pre> <pre class="hljs subunit"></pre> <p><span style="font-size: 12px; font-family: 宋体"><strong>解决方法</strong></span></p> <pre class="brush:html;gutter:true;">npm install hexo-deployer-git --save</pre> <h3 id="articleHeader13"><span style="font-size: 12px; font-family: 宋体">3.部署类型设置git</span></h3> <p><span style="font-size: 12px; font-family: 宋体">hexo 3.0 部署类型不再是<code>github</code>,<code>_config.yml</code> 中修改</span></p> <pre></pre> <pre class="brush:html;gutter:true;"># Deployment ## Docs: http://hexo.io/docs/deployment.html deploy: type: git repository: git@***.github.com:***/***.github.io.git branch: master</pre> <h3 id="articleHeader14"><span style="font-size: 12px; font-family: 宋体">4. xcodebuild</span></h3> <pre class="brush:html;gutter:true;">xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance npm install bcrypt</pre> <h3 id="articleHeader15"><span style="font-size: 12px; font-family: 宋体">5. RSS不显示</span></h3> <h4><span style="font-size: 12px; font-family: 宋体">安装RSS插件</span></h4> <pre class="brush:html;gutter:true;">npm install hexo-generator-feed --save</pre> <h4><span style="font-size: 12px; font-family: 宋体">开启RSS功能</span></h4> <p><span style="font-size: 12px; font-family: 宋体">编辑hexo/_config.yml,添加如下代码:</span></p> <pre class="hljs crmsh"></pre> <pre class="brush:html;gutter:true;">rss: /atom.xml #rss地址 默认即可</pre> <h4><span style="font-size: 12px; font-family: 宋体">开启评论</span></h4> <p><span style="font-size: 12px; font-family: 宋体">1.我使用多说代替自带的评论,在多说 网站注册 > 后台管理 > 添加新站点 > 工具 === 复制通用代码 里面有 short_name</span></p> <ol> <li> <p><span style="font-size: 12px; font-family: 宋体">在根目录 <code>_config.yml</code> 添加一行 <code>disqus_shortname: jslite</code> 是在多说注册时产生的</span></p> </li> <li> <p><span style="font-size: 12px; font-family: 宋体">复制到 <code>themes\landscape\layout\_partial\article.ejs</code></span><br><span style="font-size: 12px; font-family: 宋体">把</span></p> </li> </ol> <pre class="hljs mojolicious"></pre> <pre class="brush:html;gutter:true;"><% if (!index && post.comments && config.disqus_shortname){ %> <section id="comments"> <div id="disqus_thread"> <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> </div> </section> <% } %></pre> <pre class="hljs mojolicious"></pre> <p><span style="font-size: 12px; font-family: 宋体">改为</span></p> <pre class="brush:html;gutter:true;"><% if (!index && post.comments && config.disqus_shortname){ %> <section id="comments"> <!-- 多说评论框 start --> <div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div> <!-- 多说评论框 end --> <!-- 多说公共JS代码 start (一个网页只需插入一次) --> <script type="text/javascript"> var duoshuoQuery = {short_name:'<%= config.disqus_shortname %>'}; (function() { var ds = document.createElement('script'); ds.type = 'text/javascript';ds.async = true; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.charset = 'UTF-8'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds); })(); </script> <!-- 多说公共JS代码 end --> </section> <% } %> </pre> </div> <!--conend--> <div class="p-2"></div> <div class="arcinfo my-3 fs-7 text-center"> <a href='/t/etagid3301-0.html' class='tagbtn' target='_blank'>前端技术</a><a href='/t/etagid3110-0.html' class='tagbtn' target='_blank'>Hexo</a> </div> <div class="p-2"></div> </div> <div class="p-2"></div> <!--xg--> <div class="lbox p-4 shadow-sm rounded-3"> <div class="boxtitle"><h2 class="fs-4">相关</h2></div> <hr> <div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-534436.html">百度前端技术学院-基础-day22-24</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-534355.html">百度前端技术学院-基础-day17-18</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-449533.html">blob - hexo</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-440590.html">关于Hexo Valine 国际版 LeandCloud 评论失效的问题</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-429528.html">hexo部署码云后报错(ERROR Deployer not found: git)</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-416965.html">2019Hexo博客Next主题深度美化 打造一个炫酷博客(2)-奥怪的小栈</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-410216.html">hexo 升级5.4.0出现错误解决方法-hexo-theme-butterfly</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-343958.html">hexo博客文章增加修改历史change log</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-282731.html">基于Hexo搭建个人博客</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-258094.html">github+hexo+butterfly搭建属于自己的博客</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-244836.html">前端技术概况</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div><div class="row g-0 py-2 border-bottom align-items-center"> <div class="col-7 col-lg-11 border-lg-end"> <h3 class="fs-6 mb-0 mb-lg-2"><a href="/a/1-243743.html">如何在hexo博客中在线阅读pdf</a></h3> <div class="ltag fs-8 d-none d-lg-block"> </div> </div> </div> <!----> <!----> </div> <!--xgend--> </div> <div class="col-lg-3 col-12 p-0 ps-lg-2"> <!--box--> <!--boxend--> <!--<div class="p-2"></div>--> <!--box--> <div class="lbox p-4 shadow-sm rounded-3"> <div class="boxtitle pb-2"><h2 class="fs-4"><a href="#">标签</a></h2></div> <div class="clearfix"></div> <ul class="m-0 p-0 fs-7 r-tag"> </ul> <div class="clearfix"></div> </div> <!--box end--> </div> </div> </div> </main> <div class="p-2"></div> <footer> <div class="container-fluid p-0 bg-black"> <div class="container p-0 fs-8"> <p class="text-center m-0 py-2 text-white-50">一品网 <a class="text-white-50" href="https://beian.miit.gov.cn/" target="_blank">冀ICP备14022925号-6</a></p> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?6e3dd49b5f14d985cc4c6bdb9248f52b"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </footer> <script src="/skin/bootstrap.bundle.js"></script> </body> </html>