_config.yml配置文件說明
站點基本信息
# 站點名稱
title: 王某某的筆記
# 站點副標題
subtitle: 記錄我的編程之路
# 站點描述
description: 這是一個使用 Hexo 構建的博客,用于分享我的編程經驗和學習筆記。
# 作者名稱
author: 王某某
# 站點語言
language: zh-CN
站點的 URL 結構
# URL 前綴,例如如果站點部署在子目錄下,需要設置此項
root: /
# 生成文件的目錄
public_dir: public
# Source 文件夾
source_dir: source
# 默認布局
default_layout: post
# permalink 配置
permalink: :year/:month/:day/:title/
這里將permalink:
permalink: :title/
設置站點的時間格式和時區
# 時間格式
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# 時區設置
timezone: Asia/Shanghai
配置站點的分頁功能
# 每頁顯示的文章數
per_page: 10
# 分頁路徑
pagination_dir: page
配置404頁面
在站點根目錄創建一個名為404的新文件夾,然后在其中創建一個新頁面:
cd hexo-site
hexo new page 404
確保relative_link已禁用
relative_link: false
能否將用戶重定向到 404 頁面取決于網站托管服務商或 Web 服務器的設置,而非 Hexo 的設置。例如,如果您使用 Nginx 作為服務器,您還需要在nginx.conf文件中配置 404 頁面。
使用NexT主題
NexT 主題
github地址:
https://github.com/next-theme/hexo-theme-next
詳細安裝說明:
https://theme-next.js.org/docs/getting-started/installation.html
安裝
使用npm安裝
cd hexo-site
npm install hexo-theme-next
或者你可以克隆整個存儲庫:
cd hexo-site
git clone https://github.com/next-theme/hexo-theme-next themes/next
啟用主題
修改:Hexo的 _config.yml 文件
theme: next
默認主題是:landscape
復制主題配置文件
將主題的配置文件復制到根目錄,命名為:_config.next.yml
cd hexo-site
## npm方式安裝則:
cp ./node_modules/hexo-theme-next/_config.yml _config.next.yml
## git克隆則:
cp ./themes/next/_config.yml _config.next.yml
然后相關配置都是修改 _config.next.yml 這個配置文件
選擇方案
Scheme 是 NexT 支持的一個功能,通過使用 Scheme,NexT 可以為您提供不同的視圖。
到目前為止,NexT 支持 4 種方案,它們是:
- Muse→ Default Scheme,這是NexT的初始版本。使用黑白色調,主要看起來很干凈。
- Mist→ Muse 的更緊湊版本,具有整潔的單列視圖。
- Pisces→ 雙列方案,像鄰居的女兒一樣新鮮。
- Gemini→ 看起來像雙魚座,但有明顯的帶陰影的柱塊,看起來更加敏感。
可以通過編輯來更改方案NexT 配置文件,搜索scheme關鍵字
# Schemes
scheme: Muse
#scheme: Mist
scheme: Pisces
#scheme: Gemini
這里選Pisces
側邊欄頭像設置
# Sidebar Avatar
avatar:
# Replace the default image and set the url here.
url: /images/avatar.jpg
# If true, the avatar will be displayed in circle.
rounded: true
# If true, the avatar will be rotated with the cursor.
rotated: false
將頭像圖片avatar.jpg 放到 ./source/images/ 目錄中
配置菜單項
菜單設置項包含 3 個值:
Key: /link/ || icon
- Key→ 是菜單項的名稱(home、archives等)。如果在語言中可以找到此菜單的翻譯,則將加載此翻譯;如果沒有,Key則將使用名稱。
- 分隔符之前的值||(/link/)→ 是您網站內相對 URL 的目標鏈接。
- ||分隔符 ( ) →后的值icon是 Font Awesome 圖標的名稱。該圖標的名稱可以在Font Awesome [https://fontawesome.com/search]
中找。
默認情況下,所有菜單項均被注釋掉,以確保您可以在備用主題配置中覆蓋它們。
這里修改為:
menu:
home: / || fa fa-home
about: /about/ || fa fa-user
tags: /tags/ || fa fa-tags
categories: /categories/ || fa fa-th
archives: /archives/ || fa fa-archive
社交鏈接
# 社交鏈接設置
social:
GitHub: https://github.com/wangwen135 || fa fa-github
Weibo: https://weibo.com/your-username || fa fa-weibo
Zhihu: https://www.zhihu.com/people/your-username || fa fa-zhihu
Email: mailto:your-email@example.com || fa fa-envelope
配置Tags頁面
Next主題默認沒有Tags頁面,點擊左側菜單“標簽”會進入一個404頁面
只需要增加一個tags頁面,將頁面類型設置為tags 即可
先增加頁面
> hexo new page tags
INFO Validating config
INFO Created: D:\code\blog\blog1\source\tags\index.md
再修改頁面 ./source/tags/index.md ,設置類型
---
title: tags
date: 2024-07-24 22:18:58
type: "tags"
comments: false
---
上面菜單已經配置好了,直接重啟看效果
配置Categories頁面
默認也是沒有Categories頁面的
配置同 tags,type設置為:categories
增加頁面
hexo new page categories
頁面./source/categories/index.md 內容修改為:
---
title: categories
date: 2024-07-24 22:29:50
type: "categories"
comments: false
---
配置About頁面
categories和tags是系統已經定義好的類型,系統會自動填充內容到里面。
about頁面就不行了,得自己寫
首先創建頁面
hexo new page about
然后再修改頁面:./source/about/index.md
內容如:
---
title: about
date: 2024-07-22 22:40:20
---
### 關于我
程序員 主要做Java
----
### 關于本博客
2024年使用Hexo + Next 重建
帖子元數據設置
NexT 支持帖子創建日期、帖子更新日期和帖子類別顯示。
# Post meta display settings
post_meta:
item_text: true
created_at: true
updated_at:
enable: false
another_day: true
categories: true
關閉“更新于”
文章字數統計
安裝:hexo-word-counter
npm install hexo-word-counter
hexo clean
Hexo配置(_config.yml)中增加:
#文章字數和閱讀時間
symbols_count_time:
# 是否顯示文章的字符數
symbols: true
# 是否顯示文章的預計閱讀時間
time: true
# 是否顯示全部文章的總字符數(站點底部)
total_symbols: false
# 是否顯示全部文章總閱讀時間(站點底部)
total_time: true
# AWL 代表 Average Words per Line(每行的平均單詞數),用于估算閱讀時間。通常用于更精確的閱讀時間估算。
awl: 4
# WPM 代表 Words Per Minute(每分鐘的單詞數),用于計算閱讀時間。
wpm: 275
Next中有默認設置
symbols_count_time:
separated_meta: true
item_text_total: false
Next默認顯示字數和閱讀時長
其他設置
測試時注意:這些設置一般需要重啟服務后才能生效
回到頂部
back2top:
# 控制“返回頂部”按鈕是否啟用
enable: true
# 控制“返回頂部”按鈕是否顯示在側邊欄
sidebar: false
# 控制“返回頂部”按鈕上是否顯示滾動百分比標簽
scrollpercent: false
閱讀進度條
reading_progress:
enable: true
啟用書簽支持
bookmark:
enable: true
用戶只需點擊頁面左上角的書簽圖標即可保存滾動位置。當他們下次訪問你的博客時,他們可以自動恢復到上一次滾動位置。
深色模式
# Dark Mode
darkmode: false