Posted on 

Hexo的备忘录

[TOC]

Hexo 上传文档

在目录,使用cmd打开

image-20230227122023332

之后使用新建文章

1
hexo new post 新文章

D:\github_clone\blog\source\_posts下面有新生成的md文件

编辑文件

发布文章

1
hexo g -d

今天遇到了部署登录不上去的问题

在使用hexo g -d 部署的时候,上传失败,并要求重新输入账号密码进行上传,输入密码后报了下面的错误:

1
2
3
4
5
6
7
8
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/chunheli/chunheli.github.io.git/'
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (/Users/lichunhe/myblog/node_modules/hexo-util/lib/spawn.js:52:19)
at ChildProcess.emit (events.js:182:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)

原来是 GitHub 更改了认证策略,后续认证方式改为 token 的形式,取消了账号密码的认证方式。

如何解决呢?方式如下:

For developers, if you are using a password to authenticate Git operations with GitHub.com today, you must begin using a personal access token over HTTPS (recommended) or SSH key by August 13, 2021, to avoid disruption. If you receive a warning that you are using an outdated third-party integration, you should update your client to the latest version.

我们需要按这个网址提供的教程创建一个个人 token,有个点要注意下,创建后要记得自己找个地方保存好,因为后续你就无法再次查看到这个 token 了。

接下来重新执行 hexo d 上传博客,输入账号,密码输入刚刚创建的 token 值,就可以正常上传了。

token 我保存到,需要登录的时候,去这里复制

image-20230227122940211

image-20230227123032693

Hexo 如何置顶文章

  1. 需要主题支持
    我用的是:3-hexo

  2. 安装插件

1
npm install hexo-generator-topindex --save
  1. 设置置顶
    给需要置顶的文章加入top参数,如下:
1
2
3
4
5
6
7
8
9
10
---
title: 每天一个linux命令
date: 2017-01-23 11:41:48
top: 1
categories:
- 运维
tags:
- linux命令
---

如果存在多个置顶文章,top后的参数越大,越靠前。