惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

牧尘的NAS小站

大模型到底在干嘛 Claude 内部提示词手册公开(精选10条) AI现阶段常见新词汇出现背景(二) AI现阶段常见新词汇出现背景(一) Windows 下 OpenCV 编译与 GoCV 安装实战 CookLikeHOC:用老乡鸡的方式烹饪美味,轻松上手的JavaScript项目! SQLBot:问数新纪元的智能助手 🚀 什么是NAT?NAS远程访问绕不开的网络魔法 向量数据库介绍 MySQL慢SQL处理 NAS使用SnappyMail搭建个人WebMail 使用VirtualBox虚拟机安装群晖7.1系统 网络文件夹目前是以其他用户名和密码进行映射的 Nastool中IYUU插件修复 linux文件的特殊权限 linux文件的隐藏属性 个人下载记录 个人Docker镜像记录 Hexo配合Jenkins自动部署博客 Hexo博客放到OSS并自动更新 NAS使用timymediamanager刮削海报 群晖DSM降级指南 ls、cp、rm、mv命令详解
使用Hexo搭建个人博客
2024-02-29 · via 牧尘的NAS小站

发表于|更新于|技术随笔

|字数总计:1.3k|阅读时长:4分钟|阅读量:

我之前的博客网站都是在自己的NAS中放的,使用CND使得可以使用80和443端口访问家里NAS的博客,但是因为DDNS更换IP不及时的缘故,每天要断开几分钟,家里偶尔又会停电,导致百度和Google的收录效果奇差。无奈只得放弃在NAS放置个人博客。

不在NAS中放置博客后,我最终采用了使用纯静态网页Hexo的方式,并且将静态网也放在了OSS中,本篇主要介绍Hexo个人博客的搭建,OSS的设置放在下一篇。

搭建Hexo

需要安装nodejs,到nodejs官方网站下载最新的node并安装。

随后打开命令提示符,找到合适的位置依次输入如下命令:

1
2
npm config set registry https:
npm install -g hexo

随后创建个人博客文件夹并进入文件夹

1
2
3
4
mkdir 个人博客
cd 个人博客
hexo init
hexo server

不出意外的话,此时我们就可以使用localhost:4000来访问博客了。

安装主题

Hexo默认的主题并不一定符合我们的审美,在这里推荐下butterfly主题,也是我目前在用的
如图,从butterflygithub地址下载主题后,解压并改名为butterfly后放在themes文件夹下。

随后修改根目录的_config.yml文件,将theme改为butterfly:

1
theme: butterfly

然后使用命令安装插件

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

为了后续升级方便,我们在 hexo 的根目录创建一个文件 _config.butterfly.yml,并把butterfly目录的 _config.yml 所有内容复制到 _config.butterfly.yml 去。

网站配置

这里只给出一些基础的配置。

网站名称等配置

根据博客信息自行修改,其中url必须为博客所对应域名。

1
2
3
4
5
6
7
8
9
10
11
12

title: 牧尘的NAS小站
subtitle: '最好用的NAS使用技巧'
description: 'NAS折腾不完全指南,定期分享一些好玩的东西,不定期记录生活。'
keywords:
author: 牧尘
language: zh-CN
timezone: ''



url: https://www.dreamlyn.cn

配置文章链接

不修此配置博客也能正常使用,但当文章名为中文时,链接中容易出现中文,不利于百度收录
首先我们安装 hexo-abbrlink 插件

1
npm install hexo-abbrlink 

随后修改配置

1
2
3
4
5
6
7
8
permalink: :abbrlink.html
permalink_defaults:
abbrlink:
alg: crc32
rep: dec
pretty_urls:
trailing_index: true
trailing_html: true

添加分类和标签中英文映射。

如果我们的分类或者标签中使用了中文,那么在网页中可能会出现中文url,不利于seo,在此我们进行映射

1
2
3
4
5
6
7
8
9
10
11
12
13
14

default_category: uncategorized
category_map:
Linux基础: linux
网络基础: network
NAS技术: nasbase
NAS技术: nasservice
技术随笔: other
tag_map:
Linux基础: linux
网络: network
NAS技术: nas
反向代理: rproxy
影音系统: video

新建分类页

  1. 前往 Hexo 博客的根目录
  2. 输入 hexo new page categories
  3. 你会找到 source/categories/index.md 这个文件
  4. 修改这个文件,添加 type: “categories”
    1
    2
    3
    4
    5
    ---
    title: 分类
    date: 2018-01-05 00:00:00
    type: "categories"
    ---

新建标签页

  1. 前往 Hexo 博客的根目录
  2. 输入 hexo new page tags
  3. 你会找到 source/tags/index.md 这个文件
  4. 修改这个文件,添加 type: “tags”
    1
    2
    3
    4
    5
    6
    7
    ---
    title: 标签
    date: 2018-01-05 00:00:00
    type: "tags"
    orderby: random
    order: 1
    ---

新建友情链接页面

  1. 前往 Hexo 博客的根目录
  2. 输入 hexo new page link
  3. 你会找到 source/link/index.md 这个文件
  4. 修改这个文件,添加 type: “link”
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ---
    title: 友情链接
    date: 2022-02-22 10:34:50
    type: 'link'
    random: true
    ---


    >< 博客名称 + 博客地址 + 博客Logo + 博客简介 >
    >博客名称:
    >博客地址:
    >博客Logo:
    >博客简介:
    >(在评论中留言即可)

关于Hexo的配置还有很多,本文无法全部列出,其余配置请参照butterfy提供的中文文档,小伙伴们有哪些配置不清楚的可以在评论区留言。

其他常用插件

添加sitemap

安装依赖

1
2
λ cnpm install hexo-generator-sitemap --save 
λ cnpm install hexo-generator-baidu-sitemap --save

然后在Hexo配置文件_config.yml中添加以下代码

1
2
3
4
5

sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml

百度主动推送

安装依赖

1
λ cnpm install hexo-baidu-url-submit --save

然后在Hexo配置文件_config.yml中添加以下代码

1
2
3
4
5
baidu_url_submit:
count: 3
host: www.dreamlyn.cn
token: your_token
path: baidu_urls.txt

生成订阅

安装依赖

1
λ cnpm install hexo-generator-feed --save

然后在Hexo配置文件_config.yml中添加以下代码

1
2
3
4
5
6

feed:
type: atom
path: atom.xml
limit: 20
hub: