Github + Hexo + Shoka搭建个人博客以及遇到的部分问题

news2024/9/28 19:10:49

博客预览:

主页:

文章:

博客语言链接:

全部分类 |mmjon = = 不在能知,乃在能行

Shoka官方博客:

Yume Shoka = 優萌初華 = 有夢書架 (lostyu.me)

1、准备

1、github账号 :自行去github官网注册即可 地址:GitHub

2、Node.js环境 :去官网下载安装即可

3、Git环境 : 下载gitbash

1.1 Node.js环境

官网下载地址:https://nodejs.org/en/download/prebuilt-installer

选择预构建->默认版本直接下载

下载好之后一直next(相切换路径的也可以自行选择,没有什么影响)即可。

之后测试是否安装成功

//查看版本
node -v
//查看npm版本
npm -v

1.2 安装git

大家可以通过git官方去进行下载:https://git-scm.com/download/

选择对应的操作系统即可,同样也不要求版本

安装之后同样使用命令查看版本

git -v

2、安装Hexo

首先我们现在创建一个文件,用来保存我们一会npm安装的hexo

然后在在该目录下打开cmd,运行一下命令(建议魔法上网,没有魔法的可以尝试多运行几次)

//安装hexo
npm install -g hexo-cli
//查看是否安装成功
hexo -v
//初始化项目
hexo init
//启动查看是否构建成功
hexo server

hexo

之后我们访问http://127.0.0.1:4000/ 查看是否可以正常启动

打开能看到这个页面就是Hexo构建成功了。之后我们可以找一些好看的主题部署上去,这里我选择的是Shoka主题。

3、Shoka主题安装

3.1 安装主题

方式一、git命令

git clone https://github.com/amehime/hexo-theme-shoka.git ./themes/shoka

方式二、访问github官网下载

https://github.com/amehime/hexo-theme-shoka

这里使用第一种方式进行安装

在刚刚我们创建好的目录中打开cmd

运行git命令

安装好之后我们在themes中就能看到Shoka文件夹

之后我们还需要安装渲染插件,各种插件的用途可以到官网上进行查看

Step.1 依赖插件 - Theme Shoka Documentation - 二进制杂谈 - 计算机科学 | mmjon = = 不在能知,乃在能行

其中前两个是必须要安装的(本人尝试过不安装博客也能正常打开,就是不知道会不会出现什么问题=。=)(这里发现好像不用魔法上网会更快一些)

 npm i hexo-renderer-multi-markdown-it --save
 npm i hexo-autoprefixer --save
 npm i  hexo-algolia --save
 npm i hexo-algoliasearch --save
 npm i hexo-symbols-count-time --save
 npm i hexo-feed --save

之后我们去配置文件中配置一下主题

首先修改根目录下的_config.yml文件

将图中位置修改为Shoka,之后启动看看能不能正常运行

//hexo generate 命令用于生成静态文件,一般可以简写为 hexo g 
//hexo deploy 命令用于部署网站,一般可以简写为 hexo d
hexo g d   
//hexo server 命令用于启动本地服务器,一般可以简写为 hexo s
hexo s

发现可以正常运行了

之后我们继续进行配置,以下是我的配置,大家可以参考一下

其中这里

建议大家暂时不要改,这里是配置我们git push到github上的,如果设置了我们将无法在本地打开了(这里还没到这里的配置)这里我们还没有安装deploy的插件,后面会提到

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title:      //标题
subtitle: '不在能知,乃在能行'   //主页标题下的文字
description: '欢迎来到mmjon的笔记空间~这里主要会记录编程学习笔记🌸'   //主页个人介绍下的文字
keywords:
author: mmjon       
language: zh-CN       //默认为英文,这里可以自己设置成中文
timezone: ''

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
## 这里应该是设置我们的网站地址的,其实不改好像也没啥问题
url: http://mmjon.github.io
permalink: :title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory   目录下的各种小部件  
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
syntax_highlighter: highlight.js
highlight:
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  preprocess: true
  line_number: true
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: shoka

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repo: git@github.com:mmjon/mmjon.github.io.git
  branch: main

依旧使用 hexo g d hexo s重新构建看看效果

之后去修改主题中的各种配置,打开 thems/shoka 找到_config.yml文件

大家依旧可以参考我的来改

# Alternate site name
alternate: mmjon

open_graph:
  #twitter_id:
  #google_plus:
  #fb_admins:
  #fb_app_id:

# Assets
statics: / #//cdn.jsdelivr.net/gh/mmjon/mmjon.github.io@latest/
css: css
js: js
images: images

# themes/shoka/source/images/***
favicon:
  apple_touch_icon: /apple-touch-icon.png
  safari_pinned_tab: /logo.svg
  android_manifest: /manifest.json
  ms_browserconfig: /browserconfig.xml

# Dark Mode
# By default, the page judges whether to turn on the dark mode according to the device settings or user selection
# if `true`, the page will be displayed directly as Dark Mode, unless the user makes another choice
# 夜间模式
darkmode: false

# By default the page will automatically scroll to the last viewed position
# if `false`, automatic positioning will be turned off
# 自动定位 自动定位到上次浏览的位置
auto_scroll: true

# Whether to show the loading cat
# 是否显示页面加载动漫 就是每次都看到的那个猫猫
loader:
  start: true # When entering the page
  switch: false # When switching to another page

# click with Firework
# 页面特效 单击页面的烟花效果
fireworks:
  enable: true
  color:
     - "rgba(255,182,185,.9)"
     - "rgba(250,227,217,.9)"
     - "rgba(187,222,214,.9)"
     - "rgba(138,198,209,.9)"

# 加载谷歌字体
font:
  enable: true
  # Font options:
  # `external: true` will load this font family from `host` above.
  # `family: Times New Roman`. Without any quotes.
  # `size: x.x`. Use `em` as unit. Default: 1 (16px)

  # Global font settings used for all elements inside <body>.
  global:
    external: true
    family: Mulish
    size:

  # Font settings for alternate title.
  # 备用字体
  logo:
    external: true
    family: Fredericka the Great
    size: 3.5

  # Font settings for site title.
  # 站点字体
  title:
    external: true
    family: Noto Serif JP
    size: 2.5

  # Font settings for headlines (<h1> to <h6>).
  headings:
    external: true
    family: Noto Serif SC
    size:

  # Font settings for posts.
  posts:
    external: true
    family:

  # Font settings for <code> and code blocks.
  codes:
    external: true
    family: Inconsolata

# project of https://www.iconfont.cn/
# //at.alicdn.com/t/font_1832207_c8i9n1ulxlt.css => 1832207_c8i9n1ulxlt
iconfont: "1832207_igi8uaupcus"

# 菜单
menu:
  首页: / || home
  关于: /about/ || user
  文章:
    default: / || feather
    归档: /archives/ || list-alt
    分类: /categories/ || th
    标签: /tags/ || tags
  friends: /friends/ || heart
  links: /links/ || magic

# Social Links
# Usage: `Key: permalink || icon || color`
# Key is the link label showing to end users.
# Value before `||` delimiter is the target permalink,
# secend value is the name of Font icon.
social:
  github: https://github.com/mmjon || github || "#191717"
  #google: https://plus.google.com/yourname || google
  #twitter: https://twitter.com/yourname || twitter || "#00aff0"
  #zhihu: https://www.zhihu.com/people/yourname || zhihu || "#1e88e5"
  #music: https://music.163.com/#/user/home?id=yourid || cloud-music || "#e60026"
  #weibo: https://weibo.com/yourname || weibo || "#ea716e"
  #about: https://about.me/yourname || address-card || "#3b5998"
  #email: mailto:yourname@mail.com || envelope || "#55acd5"
  #facebook: https://www.facebook.com/yourname || facebook
  #stackoverflow: https://stackoverflow.com/yourname || stack-overflow
  #youtube: https://youtube.com/yourname || youtube
  #instagram: https://instagram.com/yourname || instagram
  #skype: skype:yourname?call|chat || skype
  #douban: https://www.douban.com/people/yourname/ || douban

sidebar:
  # Sidebar Position.
  # position: left
  position: left
  # Replace the default avatar image and set the url here.
  avatar: avatar.jpg

widgets:
  # if true, will show random posts
  # 显示随机文章
  random_posts: true
  # if true, will show recent comments
  # 显示最近评论
  recent_comments: true

footer:
  # Specify the date when the site was setup. If not defined, current year will be used.
  # 页尾全站统计局
  since: 2018
  icon:
    name: sakura rotate
    # Change the color of icon, using Hex Code.
    color: "#ffc0cb"
  # Dependencies: https://github.com/theme-next/hexo-symbols-count-time
  count: true
  powered: true

# 文章界面统计
post:
  # Dependencies: https://github.com/theme-next/hexo-symbols-count-time
  count: true

# 奖励 这里我不需要
# Reward (Donate)
#reward:
#  # If true, reward will be displayed in every article by default.
  enable: true
  account:
    wechatpay: /wechatpay.png
    alipay: /alipay.png
    paypal: /paypal.png

# TagCloud settings for tags page.
tagcloud:
  # All values below are same as default, change them by yourself.
  min: 16 # Minimun font size in px
  max: 22 # Maxium font size in px
  start: "#72cecf" # Start color (hex, rgba, hsla or color keywords)
  end: "#ffbac3" # End color (hex, rgba, hsla or color keywords)
  amount: 200 # Amount of tags, change it if you have more than 200 tags


# ---------------------------------------------------------------
# Third Party Plugins & Services Settings
# ---------------------------------------------------------------

# Creative Commons 4.0 International License.
# See: https://creativecommons.org/share-your-work/licensing-types-examples
# Available values of license: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero
# You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
# CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
creative_commons:
  license: by-nc-sa
  language: zh-CN  # deed.zh

# Comments
# Valine
# For more information: https://github.com/amehime/MiniValine
valine:
  appId: # 配置你的appId
  appKey: # 配置你的appKey
  placeholder: ヽ(○´∀`)ノ♪ # Comment box placeholder
  avatar: mp # Gravatar style : mp, identicon, monsterid, wavatar, robohash, retro
  pageSize: 10 # Pagination size
  lang: zh-CN
  visitor: true # Article reading statistic 文章阅读量统计
  NoRecordIP: false # Whether to record the commenter IP
  serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)
  powerMode: true
  tagMeta:
    visitor: 新朋友
    master: 主人
    friend: 小伙伴
    investor: 金主粑粑
  tagColor:
    master: "var(--color-orange)"
    friend: "var(--color-aqua)"
    investor: "var(--color-pink)"
  tagMember:
    master:
      # - hash of master@email.com
      # - hash of master2@email.com
    friend:
      # - hash of friend@email.com
      # - hash of friend2@email.com
    investor:
      # - hash of investor1@email.com

# bgm 背景音乐
audio:
  - title: 列表1
    list:
     - https://music.163.com/#/playlist?id=2943811283
     - https://music.163.com/#/playlist?id=2297706586
  - title: 列表2
    list:
     - https://music.163.com/#/playlist?id=2031842656

# random image api
# 随机图库
image_server: # "https://api.btstu.cn/sjbz/api.php"

# Algolia Search
# For more information: https://www.algolia.com
search:
  hits:
    per_page: 10

# Dependencies: https://github.com/amehime/hexo-renderer-multi-markdown-it
pangu: true

# Quicklink Support
# For more information: https://github.com/GoogleChromeLabs/quicklink
quicklink:
  # Custom a time in milliseconds by which the browser must execute prefetching.
  timeout: 3000
  # Default (true) will attempt to use the fetch() API if supported (rather than link[rel=prefetch]).
  priority: true

  # For more flexibility you can add some patterns (RegExp, Function, or Array) to ignores.
  # See: https://github.com/GoogleChromeLabs/quicklink#custom-ignore-patterns
  ignores:

# ---------------------------------------------------------------
# analytics & SEO Settings
# ---------------------------------------------------------------
baidu_analytics: # <app_id>

# Disable Baidu transformation on mobile devices.
disable_baidu_transformation: true

# Automatically add external URL with Base64 encrypt & decrypt.
exturl: true

# Google Webmaster tools verification.
# See: https://www.google.com/webmasters
google_site_verification:

# Bing Webmaster tools verification.
# See: https://www.bing.com/webmaster
bing_site_verification:

# Yandex Webmaster tools verification.
# See: https://webmaster.yandex.ru
yandex_site_verification:

# Baidu Webmaster tools verification.
# See: https://ziyuan.baidu.com/site
baidu_site_verification:

# Enable baidu push so that the blog will push the url to baidu automatically which is very helpful for SEO.
baidu_push: 

# 渲染md文件
markdown:
  render: # 渲染器设置
    html: false # 过滤 HTML 标签
    xhtmlOut: true # 使用 '/' 来闭合单标签 (比如 <br />)。
    breaks: true # 转换段落里的 '\n' 到 <br>。
    linkify: true # 将类似 URL 的文本自动转换为链接。
    typographer:
    quotes: '“”‘’'
  plugins: # markdown-it 插件设置
    - plugin:
        name: markdown-it-toc-and-anchor
        enable: true
        options: # 文章目录以及锚点应用的 class 名称,shoka 主题必须设置成这样
          tocClassName: 'toc'
          anchorClassName: 'anchor'
    - plugin:
        name: markdown-it-multimd-table
        enable: true
        options:
          multiline: true
          rowspan: true
          headerless: true
    - plugin:
        name: ./markdown-it-furigana
        enable: true
        options:
          fallbackParens: "()"
    - plugin:
        name: ./markdown-it-spoiler
        enable: true
        options:
          title: "你知道得太多了"

# minify 配置,压缩css/js/html
minify:
  html:
    enable: true
    exclude: # 排除 hexo-feed 用到的模板文件
      - '**/json.ejs'
      - '**/atom.ejs'
      - '**/rss.ejs'
  css:
    enable: true
    exclude:
      - '**/*.min.css'
  js:
    enable: true
    mangle:
      toplevel: true
    output:
    compress:
    exclude:
      - '**/*.min.js'

# 代码高亮
highlight:
  enable: true

prismjs:
  enable: true



autoprefixer:
  exclude:
    - '*.min.css'

# 全局搜索
algolia:
  appId:  #Your appId
  apiKey:  #Your apiKey
  adminApiKey:  #Your adminApiKey
  chunkSize: 5000
  indexName: "" #"shoka"
  fields:
    - title
    - path
    - categories
    - content:strip:truncate,0,2000
    - gallery
    - photos
    - tags


keywords: java,git,springcloud #站点关键词,用 “,” 分隔

feed:
  limit: 20
  order_by: "-date"
  tag_dir: false
  category_dir: false
  rss:
    enable: true
    template: "themes/shoka/layout/_alternate/rss.ejs"
    output: "rss.xml"
  atom:
    enable: true
    template: "themes/shoka/layout/_alternate/atom.ejs"
    output: "atom.xml"
  jsonFeed:
    enable: true
    template: "themes/shoka/layout/_alternate/json.ejs"
    output: "feed.json"


#! ---------------------------------------------------------------
#! DO NOT EDIT THE FOLLOWING `vendors` SETTINGS
#! UNLESS YOU KNOW WHAT YOU ARE DOING
#! Script dependencies will be combined with jsDelivr (cdn.jsdelivr.net)
#! ---------------------------------------------------------------
vendors:
  css:
    katex: npm/katex@0.12.0/dist/katex.min.css
    comment: css/comment.css
    fancybox: combine/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
  js:
    pace: npm/pace-js@1.0.2/pace.min.js
    pjax: npm/pjax@0.2.8/pjax.min.js
    fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js
    anime: npm/animejs@3.2.0/lib/anime.min.js
    algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js
    instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js
    lazyload: npm/lozad@1/dist/lozad.min.js
    quicklink: npm/quicklink@2/dist/quicklink.umd.js
    fancybox: combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js
    valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js
    copy_tex: npm/katex@0.12.0/dist/contrib/copy-tex.min.js
    chart: npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js

之后保存,继续使用hexo g hexo s命令重新构建

其中提示一些没必要理

主题的基本配置算是完成了,之后我们去部署到github上即可

4、部署到github

4.1 创建github page

首先我们需要去创建一个库

点击右上角+号 --> new repository

之后按照图中配置即可

之后我们需要去new 一个文件

之后写一些html的内容,并保存为index.html

创建好之后找到setting

找到page

发现github page已经生效了,我们去访问即可

如果此时你访问之后没有任何内容,不用着急,可能是github正在加载数据,等一会即可,当然,如果等了好久还没加载出来,你可以查看是不是创建时目录输入错误了

之后我们需要把项目部署到github上,那么我们有两种方式进行部署

1、最简单的方法,直接将public文件夹中的所有内容复制到github上(但是后续更改配置可能不是很好用)

2、第二种方式,配置github的私钥和公钥,同时npm安装hexo-deployer-git 部署插件

4.2 github配置私钥公钥实现git push

这里我参考的是官方文档进行配置:

首先找到github中的settings

右上角点击头像-->settings

之后找到SSH and GPG keys 新建一个ssh密钥

可以看到需要我们去填写一个sshkey

这是我们需要打开git bash 进行生成我们的keys

首先我们需要查看我们电脑上是否已经存在这么一个key

打开git bash

输入

cd ~/.ssh
ls
# 查看我们目录中是否有id_edxxx.pub或者id_rsa 如果存在的话说明我们电脑上已经有ssh密钥了

如果没有的话,我们可以使用命令进行生成,

ssh-keygen -t rsa -C "xxx@xxx.com"    //“”中输入你们的注册邮箱

之后一直回车即可

之后使用cat命令进行查看

cat id_rsa.pub 

给他全部复制下来放到我们刚刚打开的页面中

add即可

输入密码验证,可以看到我们已经创建好了

也就是说现在我们可以使用git push了

但是我们依然不能把我们的项目push到github中,因为这里我们需要把刚刚说到的插件给他安装上

npm install hexo-deployer-git --save   

并把刚刚的代码给他复制上

deploy:
  type: git
  repo: git@github.com:username/username.github.io.git
  branch: main
  

代码复制到我们的根目录下的_config.yml文件中 注意更换repo中的username为你们github的username

这里我是KELYJ 所以我改成 KELYJ/KELYJ.github.io 即可

之后使用

hexo clean
hexo g
hexo d

即可部署到github上。之后访问github我们设置好的存储库即可

KELYJ.github.io

成功,但是发现没有图片,这里的解决方法我放到下面的遇到的问题中了。

之后就是文章发布了,这里我们可以找到hexo-test\themes\shoka\example\source\_posts

目录下,官方给了好多文章模板,我们直接复制粘贴修改文件名以及编写markdown即可。

之后把文章放到hexo-test\source\_posts目录下

然后重新push即可

但是我们每次写完之后再手动上传感觉好麻烦,我们这里可以使用Github Action自动部署hexo到GitHub pages

5、使用Github Action自动部署hexo到GitHub pages(我这里并没有整好,姑且按着大佬的实现了一下,一下内容仅供参考)

首先我们需要在github中创建一个私有库(创建方式同上述创建方式,只不过需要把public选为private)

创建好之后点击settings

创建仓库密钥

name一定要填EXO_DEPLOY_KEY,

之后还是需要我们再次去生成密钥,这次我们在hexo-text文件夹中生成密钥

ssh-keygen -t rsa -b 4096 -C "Hexo Deploy Key" -f github-deploy-key -N ""

之后在 Value 填入 github-deploy-key(私钥)  中的内容

粘贴进入add就行

之后配置公钥,把公钥放到我们的公共库中也是就username.github.io库中

name需要命名为HEXO_DEPLOY_PUB(可自定义)

之后把我们的公钥内容放进去即可

Allow write access 一定要勾上

add

之后再公共库中创建文件

.github/workflows/deploy.yml

文件内容(需要对里面的内容进行修改)

# Action 的名字
name: Hexo Auto Deploy

on:
  # 触发条件1:main 分支收到 push 后执行任务。
  push:
    branches:
      - main
  # 触发条件2:手动按钮
  workflow_dispatch:

# 这里放环境变量,需要替换成你自己的
env:
  # Hexo 编译后使用此 git 用户部署到 github 仓库
  GIT_USER: username
  # Hexo 编译后使用此 git 邮箱部署到 github 仓库
  GIT_EMAIL: xxx@xxx.com
  # Hexo 编译后要部署的 github 仓库
  GIT_DEPLOY_REPO: username/username.github.io
  # Hexo 编译后要部署到的分支
  GIT_DEPLOY_BRANCH: main

#  # Hexo 编译后使用此 gitee 用户部署到gitee仓库
#  GITEE_USER: wbsu2003
#  # Hexo 编译后要部署的 gitee 仓库
#  GITEE_DEPLOY_REPO: wbsu2003/wbsu2003
#  # Hexo 编译后要部署到的分支
#  GITEE_DEPLOY_BRANCH: master

  # 注意替换为你的 GitHub 源仓库地址
  GIT_SOURCE_REPO: git@github.com:dabing85/dabing85.github.io.git
  # 注意替换为你的 Gitee 目标仓库地址
#  GITEE_DESTINATION_REPO: git@gitee.com:wbsu2003/wbsu2003.git

jobs:
  build:
    name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
    runs-on: ubuntu-latest
    if: github.event.repository.owner.id == github.event.sender.id
    strategy:
      matrix:
        os: [ubuntu-18.04]
        node_version: [12.x]

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Checkout deploy repo
        uses: actions/checkout@v2
        with:
          repository: ${{ env.GIT_DEPLOY_REPO }}
          ref: ${{ env.GIT_DEPLOY_BRANCH }}
          path: .deploy_git

      - name: Use Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node_version }}

      - name: Configuration environment
        env:
          HEXO_DEPLOY_KEY: ${{secrets.HEXO_DEPLOY_KEY}}
        run: |
          sudo timedatectl set-timezone "Asia/Shanghai"
          mkdir -p ~/.ssh/
          echo "$HEXO_DEPLOY_KEY" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
          git config --global user.name "$GIT_USER"
          git config --global user.email "$GIT_EMAIL"

      - name: Install dependencies
        run: |
          npm install hexo-cli -g
          npm install
        # 根据你安装的组件进行安装
#          npm i hexo-renderer-multi-markdown-it --save
#          npm i hexo-autoprefixer --save
#          npm i  hexo-algolia --save
#          npm i hexo-algoliasearch --save
#          npm i hexo-symbols-count-time --save
#          npm i hexo-feed --save --egacy-peer-deps
#          hexo-deployer-git --save
        # 复制中文语言包,解决菜单英文的问题
#               cp zh-CN.yml node_modules/hexo-theme-next/languages/

      - name: Deploy hexo
        run: |
          hexo clean
          hexo deploy

      # 以下为发布到gitee
#      - name: Sync to Gitee
#        uses: wearerequired/git-mirror-action@master
#        env:
#          # 直接使用了 HEXO_DEPLOY_PRI
#          SSH_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_PRI }}
#        with:
#          # GitHub 源仓库地址
#          source-repo: ${{ env.GIT_SOURCE_REPO }}
#          # Gitee 目标仓库地址
#          destination-repo: ${{ env.GITEE_DESTINATION_REPO }}

#      - name: Build Gitee Pages
#        uses: yanglbme/gitee-pages-action@main
#        with:
#          # 你的 Gitee 用户名
#          gitee-username: ${{ env.GITEE_USER }}
#          # 注意在 Settings->Secrets 配置 GITEE_PASSWORD
#          gitee-password: ${{ secrets.GITEE_PASSWORD }}
#          # 你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
#          gitee-repo: ${{ env.GITEE_DEPLOY_REPO }}
#          # 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
#          branch: ${{ env.GITEE_DEPLOY_BRANCH }}

之后我们把我们的私有库git clone到本机上

然后把我们的hexo文件复制到刚刚clone的文件夹中,之后打开git输入一下命令

git init
git add
git commit -m 'the initial edition' //版本描述
git remote add origin https://github.com/用户名/仓库名.git 
git pull
git push -u origin maste 
git push origin master

之后我们就可以通过把md文章放到私有库中的对应位置就能实现自动上传了

遇到的问题

问题一,无法git push到github上

我这里有两种原因:

1、网速太垃圾,

解决办法:魔法上网

2、你的电脑上同时存在了多个github账号的ssh密钥

解决办法:

在.ssh目录下创建config文件进行配置

touch ~/.ssh/config

之后打开你的配置文件并复制一下内容

# Account 1
Host github.com-account1   //起个别名
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_account1   //ssh文件1

# Account 2
Host github.com-account2   //起个别名
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_account2  //ssh文件2

之后使用命令进行测试,看看能不能链接成功

ssh -T git@github.com-mmjon
ssh -T git@github.com-KELYJ

成功!!!!

之后修改我的_config 为

deploy:
  type: git
  repo: git@github.com-KELYJ:KELYJ/KELYJ.github.io.git
  branch: main

重新拉取即可

问题二、图片无法正常显示

这里图片无法正常显示是因为官方图床的问题,在网上查到的有的说是新浪图床目前已经无法使用了 ,也有的说不是新浪图床,这里我也不没有查清到底是什么原因,反正总而言是就是图床坏了,这里我们修改掉这个图床就好了!!!!

首先我们需要找到/themes/shoka/scripts/helpers中的engine.js

之后我们找到第31行处,修改这个return后面的内容为

https://lz.sinaimg.cn/'+size+'/'+img

这里找到的是github上shoka主题官方问答模块中一个大佬分享的链接(这里直接跪谢大佬!!!▄█▀█●▄█▀█●▄█▀█●)

之后重新上传就可以解决这个问题了。

参考文章:

Hexo+shoka主题+github/服务器搭建个人博客-CSDN博客

利用GitHub Actions 自动部署 Hexo博客 全自动运行 不知所措的新哥 - 哔哩哔哩 (bilibili.com)

GitHub Actions 来自动部署 Hexo - 知乎 (zhihu.com)

Github配置ssh key的步骤(大白话+包含原理解释)_github生成ssh key-CSDN博客

Hexo 主题 Shoka & multi-markdown-it 渲染器使用说明 - Theme Shoka Documentation - 二进制杂谈 - 计算机科学 | Yume Shoka = 優萌初華 = 有夢書架 (lostyu.me)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2174500.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

人生苦短,我用Python✌

面向代码的解释型语言 数据开发和AI 编程语言:让计算机了解我们干什么&#xff0c;翻译官 1.下载软件 解释器安装 点击第二个 改路径 D:\python 安装 测试 winr打开 输入代码 输出 退出环境 exit&#xff08;&#xff09; 新建文本文档后缀改成py 编写 运行 安装编写代码…

MySQL 性能剖析全攻略

在使用 MySQL 数据库的过程中&#xff0c;性能问题往往是让开发者和管理员头疼的难题。为了有效地解决这些问题&#xff0c;我们需要对 MySQL 进行性能剖析。那么&#xff0c;如何在 MySQL 中进行性能剖析呢&#xff1f;本文将为你详细介绍。 一、为什么要进行性能剖析&#x…

$attrs 与 $listeners 怎么用

在组件 son、grandson 和 great-grandson 中都显示了 this is a sentence&#xff0c;而子组件 son 和孙组件 grandson 中都没有定义 props&#xff0c;说明 parent 组件中的数据正确的传递到了内部组件中。 打开控制台&#xff0c;分别点击组件 grandson 和 great-grandson 中…

用Python实现运筹学——Day 5: 单纯形法介绍

一、学习内容 1. 单纯形法的基本原理与步骤 单纯形法&#xff08;Simplex Method&#xff09;是求解线性规划问题的一种常用方法。它是一种迭代算法&#xff0c;用于在凸多边形的顶点上寻找目标函数的最优解&#xff0c;通常用于多变量的线性规划问题。单纯形法主要应用于线性…

如何查看上网记录及上网时间?5种按步操作的方法分享!【小白也能学会!】

“知己知彼&#xff0c;百战不殆”&#xff0c;在数字时代&#xff0c;了解自己的上网行为和时长&#xff0c;不仅能帮助我们更好地管理时间&#xff0c;还能提升工作效率和生活质量。 今天&#xff0c;我们就来分享五种简单易懂的方法&#xff0c;即便是网络小白也能轻松学会…

大模型分布式训练并行技术(九)-总结

近年来&#xff0c;随着Transformer、MOE架构的提出&#xff0c;使得深度学习模型轻松突破上万亿规模参数&#xff0c;传统的单机单卡模式已经无法满足超大模型进行训练的要求。因此&#xff0c;我们需要基于单机多卡、甚至是多机多卡进行分布式大模型的训练。 而利用AI集群&a…

基于Qt/C++UDP 调试软件功能及用途介绍

概述 UDP 调试软件是一个基于 Qt 框架的图形化应用程序&#xff0c;旨在提供一个简单易用的界面用于测试和调试 UDP&#xff08;用户数据报协议&#xff09;通信。该软件支持客户端和服务器模式&#xff0c;能够实现数据的发送和接收&#xff0c;方便开发者和网络工程师进行网…

PG数据库的Jsonb全文检索查询

1.操作键值对 PostgreSQL 对 jsonb 类型的筛选查询可以使用 -> 或者 ->> 操作符。 -> 操作符用于通过 JSON 对象中的键来获取对应的值。->> 操作符可以将获取到的值提取出来转化为字符串类型。 例如&#xff0c;下面是一个包含 jsonb 类型字段的表&#x…

企业IT安全重保服务:守护关键时刻的坚固防线

中国联通国际有限公司产品之IT安全重保服务&#xff1a;守护关键时刻的坚固防线 在数字化时代&#xff0c;信息安全已成为企业运营与国家安全的基石。随着各类重大活动、会议及内部专项工作的频繁举行&#xff0c;如何确保信息系统在关键时刻免受黑客攻击、网页篡改、病毒感染…

零工市场小程序的未来发展趋势

随着经济的发展&#xff0c;越来越多的人们选择了灵活就业的方式来工作&#xff0c;零工市场小程序作为灵活就业一个重要的媒介&#xff0c;未来的发展趋势如何呢&#xff1f; 其实在零工市场小程序中&#xff0c;有着大数据的分析、算法&#xff0c;可以精准的匹配到自由职业…

深度学习常见术语介绍

文章目录 数据集&#xff08;Dataset&#xff09;特征&#xff08;Feature&#xff09;标签&#xff08;Label&#xff09;训练集&#xff08;Training Set&#xff09;测试集&#xff08;Test Set&#xff09;验证集&#xff08;Validation Set&#xff09;模型&#xff08;Mo…

基于Hive和Hadoop的哔哩哔哩网站分析系统

本项目是一个基于大数据技术的哔哩哔哩平台分析系统&#xff0c;旨在为用户提供全面的哔哩哔哩视频数据和深入的用户行为分析。系统采用 Hadoop 平台进行大规模数据存储和处理&#xff0c;利用 MapReduce 进行数据分析和处理&#xff0c;通过 Sqoop 实现数据的导入导出&#xf…

金镐开源组织成立,增加最新KIT技术,望能为开源添一把火

国内做开源的很多&#xff0c;知名的若依、芋道源码、Pig、Guns等&#xff0c;可谓是百花齐放&#xff0c;虽然比不上Apache&#xff0c;但也大大提高了国内的生产力。经过多年的发展&#xff0c;一些开源项目逐渐也都开始商业化。基于这样的背景&#xff0c;我拉拢了三个技术人…

SO-ELM预测 | MATLAB实现SO-ELM蛇群算法优化极限学习机多输入单输出

回归预测 | MATLAB实现SO-ELM蛇群算法优化极限学习机多输入单输出 目录 回归预测 | MATLAB实现SO-ELM蛇群算法优化极限学习机多输入单输出效果一览基本介绍程序设计效果一览 基本介绍 Matlab实现SO-ELM蛇群算法优化极限学习机多变量回归预测 1.data为数据集,7个输入特征,1个输…

SIGA 气路柜系统VAPORIZER SYSTEM VS-111-321 含电路图

SIGA 气路柜系统VAPORIZER SYSTEM VS-111-321 含电路图

stm32单片机个人学习笔记8(TIM输出比较)

前言 本篇文章属于stm32单片机&#xff08;以下简称单片机&#xff09;的学习笔记&#xff0c;来源于B站教学视频。下面是这位up主的视频链接。本文为个人学习笔记&#xff0c;只能做参考&#xff0c;细节方面建议观看视频&#xff0c;肯定受益匪浅。 STM32入门教程-2023版 细…

第一批学Ai绘画的人,到底是怎么变现的?变现方式详细拆解!

Ai绘画技术发展到现在&#xff0c;已经有不少人通过这个渠道实现了变现。 我们在羡慕别人赚钱的同时&#xff0c;也应该从中不断地总结&#xff0c;思考哲轩变现方式的共同之处&#xff0c;在总结出找到属于自己的变现方式。 今天我就结合一些以往变现的成功案例&#xff0c;…

UnityShader 一种RGB分离效果

UnityShader 一种RGB分离效果 前言项目ASE截图 前言 看到一种RGB分离的Shader效果&#xff0c;记录一下。 项目 ASE截图

JavaEE: 探索网络世界的核心-IP协议

文章目录 IP 协议协议头格式IP 地址IP地址的数量限制解决IP不够用的问题 IP 地址的网段划分子网掩码ABCDE五类网络 特殊的 IP 地址 IP 协议 协议头格式 4位版本号: 只有两个取值,4(IPv4)和6(IPv6). IPv2,IPv5这些在实际中是没有的,可能是理论上/实验室中存在~ 4位首部长度: IP…

Adobe PR与AE的区别与联系(附网盘地址)

从事视频后期制作的小伙伴&#xff0c;对于PR&#xff08;Premiere&#xff09;和AE&#xff08;After Effects&#xff09;应该不会陌生。随着短视频的兴起&#xff0c;就连我们普通用户&#xff0c;拍摄完视频&#xff0c;都会去糟取精的剪辑一下&#xff0c;而PR正是一款功能…