博客
博客推荐
个人博客
- 个人博客有很多中方式布置,目前选择的是 github page 方式部署 使用hexo框架构建
一、前置准备
- github 账号 – https://github.com/
- git工具– https://git-scm.com/
- nodeJS环境—https://nodejs.org/zh-cn
二、创建github仓库
- 在github上创建一个新的代码仓库用于保存我们的博客
- 注意仓库名字的格式为用户名.github.io
三、hexo
初始化
# 安装hexo npm install -g hexo-cli # 初始化 文件夹 为hexo-blog的博客 hexo init hexo-blog # 安装 cd hexo-blog npm install # 本地编译及启动 hexo g hexo server
然后在博客目录下创建 `_config.fluid.yml`,将主题的 [_config.yml](https://github.com/fluid-dev/hexo-theme-fluid/blob/master/_config.yml) 内容复制进去。 2. 下载最新release解压到 themes 目录,并将解压出的文件夹重命名为 `themsName`1
2
3
4
5
6
7
8
9
10### 更换主题
+ https://hexo.io/themes/
+ 推荐主题:
+ fluid(https://github.com/fluid-dev/hexo-theme-fluid)
+ 用户手册:https://hexo.fluid-dev.com/docs/
+ next:(https://github.com/next-theme/hexo-theme-next)
+ 安装过程:
1. Hexo 5.0.0 版本以上,推荐通过 npm 直接安装,进入博客目录执行命令:
```shell
npm install --save hexo-theme-fluid- 指定主题:
- 如下修改 Hexo 博客目录中的
_config.yml
:1
2theme: themsName # 指定主题
language: zh-CN # 指定语言,会影响主题显示的语言,按需修改
- 如下修改 Hexo 博客目录中的
发布到github page
方式一、安装hexo-deployer-git
- 安装hexo-deployer-git
1
npm install hexo-deployer-git --save
- 修改根目录下的
_config.yml
,配置GitHub
相关信息1
2
3
4
5deploy:
type: git
repo: git@github.com:X-Leonidas/X-Leonidas.github.io.git
branch: main
token: token 为 GitHub 的 Personal access tokens
方式二、 直接提交到github
- 直接将
public
目录中的文件和目录推送至GitHub
仓库和分支中。
部署到服务器
- TODO
提交到google 收录
- 确认是否被收录
- 以本网站为例,打开Google,输入
site: XXXXXXX.github.io
,如果Google提示“找不到相符的内容”,则说明你的网站尚未被Google收录。如果网站已经被收录,Google会自动查询和网站有关的内容
- 以本网站为例,打开Google,输入
- 验证网站所有者
- 只有向搜索引擎添加并认证网站,证明自己是该域名的拥有者和管理者后,搜索引擎可以快速批量添加该域名下的所有子站点,而无需一一验证。认证完成后还可以使用Google Console查看并管理网站的访问统计等
- 前往Google Console
- 选择网页前缀资源类型
- 验证方式选择:HTML文件验证
- 下载HTML文件后,对于Hexo,将该文件放在Hexo根目录下
/source
文件中。然后hexo g -d
,等待部署。当你能够在浏览器中输入https://XXXXXX/googleXXXXXXX.html
并成功跳转时,说明该文件已经添加成功。注意: 跳转后必须是原始的html页面才算成功,对于hexo下的fluid,要在googleXXXXXXX.html添加如下字段1
2
3
4layout: false
---
此处需要空一行
google-site-verification: xxxxx.html - 添加后部署到线上,部署完成后在Google Console中点击验证
- 添加站点地图
为启用站点地图,首先要在Hexo根目录中Git Bash来安装插件:
1
2
3npm install hexo-generator-sitemap --save
ADA在站点配置文件(不是主题配置文件!)
_config.yml
中添加:1
2
3# Auto Generate sitemap
sitemap:
path: sitemap.xml然后
hexo g -d
,若/public
文件夹下生成了sitemap.xml
,并且浏览器能够访问https://XXXXX/sitemap.xml
,说明创建成功。注意: 生成sitemap.xml 如果文件名中包含**&** ,会生成失败
在Google Console中,左侧栏选择“站点地图”,在“添加新的站点地图”中,输入你的站点地图网址,比如
sitemap.xml
。提交成功后,Google会在“已提交的站点地图”中显示该sitemap。索引需要一段时间编制并生效。通常情况下,48小时内Google即可完成收录。
博客
https://x-leonidas.github.io/2024/10/09/22tool/博客/