程序员的资源宝库

网站首页 > gitee 正文

Hello-hexo(hello minecraft)

sanyeah 2024-04-04 11:07:14 gitee 7 ℃ 0 评论

一次完整的Hexo写作流程

https://fuguigui.github.io/hexo2/

总结来说,最常用的套路就是

  1. hexo g; hexo s本地预览,再更改(文章内容自动实时状态),直到满意为止

  2. hexo d; 或者hexo g; hexo d远程部署。

新建一遍随笔文章

hexo n 0模版 xxx

hexo 如何写多个tag

类似与数组,必须使用逗号, 隔开各个tag
比如:[AI,人脸识别,人脸对比,机器人脸比对,批量人脸比对]

第二种方法是:

  • 如何使用hexo
  • hexo

关于github如何重新运行deployment:发布文章至github.io

打开链接:https://github.com/chuanzhuo/blog/actions/runs/6364108418/job/17311236272
Re-run jobs

历史记录和查看当前workflow运行的情况:https://github.com/chuanzhuo/blog/actions

如何插入代码段?

前后单独段落的三个撇:```

$ sudo -i

插入本地图片

这里主要参考这篇文章赵大宝hexo-images,

举例说明(设置大小和样式) { % img http://www.viemu.com/vi-vim-cheat-sheet.gif 200 400 vi-vim-cheat-sheet % }
这个功能太赞了,我终于可以链接我的Evernote存储的Skitch应用(发布的链接)来方便地展示图片了!

第二种支持的图片语法(比较通用)

<img src= https:// >

让hexo的首页只显示文章的部分内容而不是全部
在文章的 front-matter 中添加 description,并提供文章摘录
如何加入到模版中,每次hexo new ""的时候,自动有这个标签?

使用表格

首页 配置页
	| 标题1 | 标题2 | 标题3 |
	| ------ | ------ | ------ |
	| 文本好短 | 文本不短也不长 | 文本好长文本好长文本好长 |
	| 文本好长文本好长文本好长 | 文本好短 | 文本不短也不长 |

官方中文文档

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

大方向(大体)思路

https://cloud.tencent.com/developer/article/1546392

步骤参考

使用hexo在GitHub上搭建个人博客
https://developer.aliyun.com/article/940387

存储位置:

https://github.com/chuanzhuo/blog

Hexo Markdown 简明语法手册

怎么安装新的hexo插件,步骤如下:

比如:https://github.com/next-theme/hexo-generator-searchdb

  1. Installation
    • $ npm install hexo-generator-searchdb
  2. Detail Configuration

hexo next 不生成tag页面解决方案

https://blog.csdn.net/yinjiangQAQ/article/details/103951416

hexo 阅读排行榜

感觉不好弄,而且需要依赖另外一个计数系统 https://www.jianshu.com/p/27b971d84f76

hexo 自动生成url, 文章URL设置

一直没有安装那个自定义文章URL的插件,主要是考虑到个人喜好:尽量避免安装过多插件(仅留下长期使用的)

  1. 今日切换到懒人模式, 使用hash值
    这个方案虽然无法自定义文章url,但是hash值是根据文件名和日期自动生成的,只要我不修改文章标题(同文件名)
    url值就会永久保留。
    虽然无法做到SEO友好的url,但我不能给我自己增加开启一遍新的随笔的动力,不给自己添堵。
  2. 最终切换为对人类更友好的日期模式。

参考:
hexo文章url设置
Hexo永久链接(Permalinks)生成方式比较

Note:宝塔 部署 Hexo,没有意义。hexo 写博客流程

github.io
还是选择使用hexo.io的构架,能长久!文档,本地编辑,git。
不依赖vps或服务器。
.md文件的编辑罢了
放弃方案:使用宝塔面板快速搭建Typecho个人博客(图文教程)

hexo这种模式的优点

  • 可以极其方便地不停的更新文章内容,版本不停迭代,(不再像cnblogs发布后,不搭理文章了,由于维护很麻烦,人的惰性成为一大阻力)

  • 样式和设置随时更新,极其方便的hexo -g即可本地实时预览到(hexo -s 如果一直开着,会自动动态刷新)

  • 不需要VPS,不受制于具体的平台或服务

  • Next 说明:https://theme-next.js.org/docs/theme-settings/footer.html?highlight=copyright

  • 设置了security插件,说明:
    https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/ReadMe.zh.md

hexo

hexo文末 添加本文的url

解决慢慢迁移到新blog的长远目标

20231024 文末添加当前文章链接和版权声明
hexo-addlink 文末添加当前文章链接和版权声明 https://github.com/acwong00/hexo-addlink
原来这个插件已经6-7年前的了,无效了。直接使用NexT中的设置即可解决
文章链接和版权声明需求。

creative_commons:
  # Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero
  license: by-nc-sa
  # Available values: big | small
  size: small
  sidebar: true
  post: true

可是生成的本文链接地址不正确(不是https://chuanzhuo.github.io/blog/)

文末添加当前文章日期信息

编辑NexT中的post-followme.njk
文件目录:》themes〉next》layout〉_partials 》 post
添加如下到div中(从#33行以下是添加的),为方便你直接使用,贴出修改后的.njk全文:

<div class="followme">
  <span>{{ __('follow_me.welcome') }}</span>

  <div class="social-list">
    {%- for name, value in theme.follow_me %}
      {%- set link = value.split('||')[0] | trim %}
      {%- set icon = value.split('||')[1] | trim if value.split('||')[1] else '' %}

      <div class="social-item">
        {%- if link.endsWith('.png') or link.endsWith('.jpg') %}
          <span class="social-link">
            <span class="icon">
              <i class="{{ icon }}"></i>
            </span>

            <span class="label">{{ name }}</span>
          </span>

          <img class="social-item-img" src="{{ url_for(link) }}">
        {%- else %}
          <a target="_blank" class="social-link" href="{{ url_for(link) }}">
            <span class="icon">
              <i class="{{ icon }}"></i>
            </span>

            <span class="label">{{ name }}</span>
          </a>
        {%- endif %}
      </div>
    {%- endfor %}
  </div>

  {%- set date_diff = date(post.date) != date(post.updated) %}
    {%- set time_diff = time(post.date) != time(post.updated) %}
    {%- if theme.post_meta.created_at %}
      <span>
        <span class="post-meta-item-icon">
          <i class="far fa-calendar"></i>
        </span>
        <span class="post-meta-item-text">{{ __('post.posted') }}</span>

        {%- if not date_diff and time_diff and theme.post_meta.updated_at.enable and theme.post_meta.updated_at.another_day %}
          {%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) + ' / ' + __('post.modified') + __('symbol.colon') + time(post.updated) %}
        {% else %}
          {%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) %}
        {%- endif %}

        <time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{{ date(post.date) }}</time>
      </span>
    {%- endif %}
    {%- if theme.post_meta.updated_at.enable and (not theme.post_meta.updated_at.another_day or date_diff or not theme.post_meta.created_at) %}
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">{{ __('post.edited') }}</span>
        <time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{{ date(post.updated) }}</time>
      </span>
    {%- endif %}
</div>

关于404页面

需要在html头添加一个自动跳转的功能
(由于所有文章生成的链接有变动,导致404页面变得重要了)
编辑位置 /source/404/index.md


<script>
    document.location = 'https://chuanzhuo.github.io/blog/'
</script>

hexo使用Artalk评论系统

https://www.iots.vip/post/hexo-artalk-comment.html

痛点:目前我不知道我的那些文章是最近被关注的?
https://statcounter.com/p12934590/visitor/

blog的文章浏览的监控/统计,
即便是一个简单的列表,今日或昨日,有多少人浏览了那些html页面,排行榜
这样我就可以针对这些文章进行,更新,改进,迭代。

可否直接使用http的服务?避免使用域名的门槛问题
不可以

Artalk 的IP归属地检测,仍然失效,如何解决?(不知道如何调试)
已下载并配置:./data/ip2region.xdb
移动4G网络仍然无法访问https://@.carlzeng.top:@
具体步骤和笔记详见:(《Hexo定制之家宽部署artalk评论系统》)[https://www.carlzeng.top/202310261222.html]
外网正常后,IP归属地检测自动就正常了

3年或6-7年以前的hexo插件就不要考虑了

比如:https://github.com/huiwang/hexo-recommended-posts
实践了半天,也可能是服务器早就挂了
https://www.npmjs.com/package/hexo-recommended-posts?activeTab=explore
严重质疑这个npm,保留一堆过时的包。

添加最近的文章 How to add recent posts to Next theme(v8.x.x)

https://egbert-yu-ting.github.io/posts/68394953/
调整半天的css, 在sidebar.njk中;务必是在_data文件夹下。
In the /blog/source/ path, establish _data/sidebar.njk file under source/ directory, and add contents into sidebar.njk as below:

    <!-- recent posts -->
    {%- if theme.recent_posts %}
      <div class="sidebar-inner sidebar-overview-active animated fadeInUp">
            <div class="links-of-blogroll-title recent-posts-title">
          <i class="fa fa-history {{ theme.recent_posts_icon | lower }}" aria-hidden="true"></i>
                {{ theme.recent_posts_title }}
        </div>
        <ul class="links-of-blogroll-list recent-posts-list">
            {%- set posts = site.posts.sort('-date').toArray() %}
            {%- for post in posts.slice('0', '5') %}
                <li class="popular-posts-item">
                  <a href="{{ url_for(post.path) }}" title="{{ post.title }}" target="">
                  {{ post.title }}
                  </a>
                </li>
            {%- endfor %}
        </ul>
      </div>
    {%- endif %}

解决每次hexo clean后都要手动添加wechat_channel.png到public目录

由于hexo clean会删除public文件夹,需要把固定住的突破保存到》themes〉next》source〉image

新版hexo 的next 怎么把分页的数量调多点?

打开 ./themes/next/layout/_partials/pagination.njk 文件,
找不到 mid_size 字段,指向next_paginator函数。
打开 ./themes/next/script/helpers/next-paginator.js 文件
仅修改mid_size字段内容,修改完效果如下:

  let paginator = this.paginator({
    prev_text: '<i class="fa fa-angle-left"></i>',
    next_text: '<i class="fa fa-angle-right"></i>',
    mid_size : 5,
    escape   : false
  });

Next

  • [Done]考虑是否将cnblogs里面备份下来的xml文件,如何重新发布到hexo中?
  • 学习:https://www.itfanr.cc/about
    • hexo博客通过webhook自动部署到个人VPS
    • 插件列表:Hexo博客 | 插件推荐

Best

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表