用hexo搭建个人博客

下载nodejs

官方网址:https://nodejs.org/en/
下载LTS版本的就可以

在这里插入图片描述

打开powershell

不是windows的打开终端输入命令 sudo su
以管理员身份运行
在这里插入图片描述

检查nodejs版本

C:\WINDOWS\system32>node -v
v12.18.4

C:\WINDOWS\system32>npm -v
6.14.6

安装hexo

用npm安装cnpm

国内镜像源很慢,用npm安装cnpm,指向淘宝的源


C:\WINDOWS\system32>npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this
C:\Users\MECHREOV\AppData\Roaming\npm\cnpm -> C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\cnpm\bin\cnpm
+ cnpm@6.1.1
added 685 packages from 971 contributors in 24.785s

安装hexo


C:\WINDOWS\system32>cnpm install -g hexo-cli
Downloading hexo-cli to C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli_tmp
Copying C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli_tmp\_hexo-cli@4.2.0@hexo-cli to C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli
Installing hexo-cli's dependencies to C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli/node_modules
[1/10] abbrev@^1.1.1 installed at node_modules\_abbrev@1.1.1@abbrev
[2/10] tildify@^2.0.0 installed at node_modules\_tildify@2.0.0@tildify
[3/10] minimist@^1.2.5 installed at node_modules\_minimist@1.2.5@minimist
[4/10] bluebird@^3.5.5 installed at node_modules\_bluebird@3.7.2@bluebird
[5/10] command-exists@^1.2.8 installed at node_modules\_command-exists@1.2.9@command-exists
[6/10] hexo-log@^2.0.0 installed at node_modules\_hexo-log@2.0.0@hexo-log
[7/10] resolve@^1.11.0 installed at node_modules\_resolve@1.17.0@resolve
platform unsupported hexo-fs@3.1.0 › chokidar@3.4.2 › fsevents@~2.1.2 Package require os(darwin) not compatible with your platform(win32)
[fsevents@~2.1.2] optional install error: Package require os(darwin) not compatible with your platform(win32)
[8/10] hexo-fs@^3.0.1 installed at node_modules\_hexo-fs@3.1.0@hexo-fs
[9/10] chalk@^4.0.0 installed at node_modules\_chalk@4.1.0@chalk
[10/10] hexo-util@^2.0.0 installed at node_modules\_hexo-util@2.4.0@hexo-util
Recently updated (since 2020-09-12): 3 packages (detail see file C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\.recently_updates.txt)
  2020-09-14
    → hexo-util@2.4.0 › htmlparser2@4.1.0 › domelementtype@^2.0.1(2.0.2) (04:49:06)
    → hexo-util@2.4.0 › htmlparser2@4.1.0 › domutils@^2.0.0(2.3.0) (03:09:30)
    → hexo-util@2.4.0 › htmlparser2@4.1.0 › domutils@2.3.0 › dom-serializer@^1.0.1(1.1.0) (04:13:48)
All packages installed (61 packages installed from npm registry, used 2s(network 2s), speed 837.78kB/s, json 61(134.86kB), tarball 1.39MB)
[hexo-cli@4.2.0] link C:\Users\MECHREOV\AppData\Roaming\npm\hexo@ -> C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli\bin\hexo

检查hexo版本

C:\WINDOWS\system32>cnpm -v
cnpm@6.1.1 (C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\cnpm\lib\parse_argv.js)
npm@6.14.8 (C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\cnpm\node_modules\npm\lib\npm.js)
node@12.18.4 (E:\Node.js\node.exe)
npminstall@3.27.0 (C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Users\MECHREOV\AppData\Roaming\npm
win32 x64 10.0.18363
registry=https://r.npm.taobao.org

C:\WINDOWS\system32>hexo -v
hexo-cli: 4.2.0
os: Windows_NT 10.0.18363 win32 x64
node: 12.18.4
v8: 7.8.279.23-node.39
uv: 1.38.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.16.0
modules: 72
nghttp2: 1.41.0
napi: 6
llhttp: 2.1.2
http_parser: 2.9.3
openssl: 1.1.1g
cldr: 37.0
icu: 67.1
tz: 2019c
unicode: 13.0

创建blog存放目录

windows的可以直接创建文件夹,如果是linux的就在自己的目录mkdir创建目录,然后cd进去,pwd常看一下当前目录

在这里插入图片描述

hexo初始化博客

安装git

这里注意如果电脑没有安装git的话会出错的,如果已经安装git或者类似的可以直接进行第二步

git官方网址 :https://git-scm.com/download/win
这个是windows的,选择自己相对应的版本
在这里插入图片描述

如果下载需要亿点时间的话,像我这样,建议手机开热点下载,十几秒就下载完了

在这里插入图片描述

初始化博客

首先要进入你创建好的目录下进行初始化
如果超过几分钟的话需要中断然后连接手机热点下载,也要把你存放blog的目录清空再重新初始化

在这里插入图片描述

PS E:\blog> hexo init
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
[32mINFO [39m Install dependencies
added 183 packages from 421 contributors and audited 189 packages in 15.106s

10 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

INFO  Start blogging with Hexo!

查看生成了那些东西

PS E:\blog> ls


    目录: E:\blog


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2020/9/20     11:02                node_modules
d-----        2020/9/20     11:01                scaffolds
d-----        2020/9/20     11:01                source
d-----        2020/9/20     11:01                themes
-a----        2020/9/20     11:01             71 .gitignore
-a----        2020/9/20     11:02          56414 package-lock.json
-a----        2020/9/20     11:01            602 package.json
-a----        2020/9/20     11:01           2545 _config.yml

在这里插入图片描述

启动博客

hexo s
s是server的简写

PS E:\blog> hexo s
INFO  Validating config
INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

在本地的4000端口查看一下

在这里插入图片描述

新建一个博客文章

创建一篇博客文章

PS E:\blog> hexo new "我的第一篇博客"
INFO  Validating config
INFO  Created: E:\blog\source\_pos

进入E:\blog\source_posts目录下
用记事本编辑刚创建的博客(windows)
如果不是windows可以cd进入然后vim编辑

在这里插入图片描述

编辑完成后需要clean清理一下,需要在blog这个目录下清理,如果是mac或者linux进入source_posts目录下编辑文章的需要cd …/…返回到blog目录下

在这里插入图片描述

PS E:\blog> hexo clean
INFO  Validating config
INFO  Deleted database.

生成静态文件

PS E:\blog> hexo generate
INFO  Validating config
INFO  Start processing
INFO  Files loaded in 727 ms
INFO  Generated: archives/index.html
INFO  Generated: fancybox/blank.gif
INFO  Generated: archives/2020/index.html
INFO  Generated: archives/2020/09/index.html
INFO  Generated: index.html
INFO  Generated: fancybox/helpers/fancybox_buttons.png
INFO  Generated: fancybox/fancybox_loading.gif
INFO  Generated: fancybox/fancybox_overlay.png
INFO  Generated: fancybox/fancybox_sprite.png
INFO  Generated: fancybox/fancybox_sprite@2x.png
INFO  Generated: fancybox/fancybox_loading@2x.gif
INFO  Generated: js/script.js
INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.css
INFO  Generated: fancybox/jquery.fancybox.css
INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.js
INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.js
INFO  Generated: fancybox/helpers/jquery.fancybox-media.js
INFO  Generated: css/fonts/fontawesome-webfont.ttf
INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.css
INFO  Generated: css/style.css
INFO  Generated: css/fonts/fontawesome-webfont.woff
INFO  Generated: fancybox/jquery.fancybox.pack.js
INFO  Generated: css/fonts/FontAwesome.otf
INFO  Generated: css/fonts/fontawesome-webfont.eot
INFO  Generated: 2020/09/20/我的第一篇博客/index.html
INFO  Generated: fancybox/jquery.fancybox.js
INFO  Generated: 2020/09/20/hello-world/index.html
INFO  Generated: css/images/banner.jpg
INFO  Generated: css/fonts/fontawesome-webfont.svg
INFO  29 files generated in 1.62 s

启动

生成以后在重新启动一下
就可以看到新建的博客了

PS E:\blog> hexo se
INFO  Validating config
INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

在这里插入图片描述

创建gitee账户

设置个人地址

全名尽量和个人地址一样,就不要瞎改了

创建新仓库
在这里插入图片描述

ssh

PS E:\blog> ssh-keygen -t rsa -C “sunbursts@hexo.com”
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\MECHREOV/.ssh/id_rsa):
Created directory ‘C:\Users\MECHREOV/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\MECHREOV/.ssh/id_rsa.
Your public key has been saved in C:\Users\MECHREOV/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:rjYmy22NzibZ+jIRUDzj4WZCI+cohM5V1thZnfamqYI sunbursts@hexo.com
The key’s randomart image is:
±–[RSA 2048]----+
|. ooo+ o… . |
|o.=.. + + |
|+
.= + . . |
|ooo * o |
|. + . |
| +.o. . |
| .EOo… |
| +#
… |
±—[SHA256]-----+
PS E:\blog> cat C:\Users\MECHREOV.ssh\id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7PA2i2UtopApOByAq1jnBS4r6yoSVbFBcdeTdknvMX01D/x1jVZAeLD+rQIYDTEYu24SkI5NXs8ErEfQWM3QZ+FxI/Kr39BkaROSx0UFzH43s1kRyZG0rW+7COtlPpQDgRwe6OI+2eJCfssQ3V1WgWB5ETCQjSaVDcpezL2+TKMbaVWsACn8vYiZplGIVp8jhmEPq4tmjCFEdx2FTHMFxwaf3nmioH/LjwOdAvBH72z3sE6/L61oqbhYPFc7F5xfrv0mn+x7CDU54DDHn sunbursts@hexo.com

在这里插入图片描述
在这里插入图片描述

PS E:\blog> ssh -T git@gitee.com
The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
Hi [36;01mafu[0m! You've [32msuccessfully[0m authenticated, but GITEE.COM does not provide shell access.

在这里插入图片描述

在blog目录下装git部署插件

PS E:\blog> cnpm install --save hexo-deployer-git
\ [0/1] Installing fill-range@^7.0.1platform unsupported hexo-deployer-git@2.1.0 › hexo-fs@2.0.1 › chokidar@3.4.2 › fsevents@~2.1.2 Package require os(darwin) not compatible with your platform(win32)
[fsevents@~2.1.2] optional install error: Package require os(darwin) not compatible with your platform(win32)
√ Installed 1 packages
√ Linked 78 latest versions
√ Run 0 scripts
Recently updated (since 2020-09-13): 4 packages (detail see file E:\blog\node_modules\.recently_updates.txt)
√ All packages installed (80 packages installed from npm registry, used 3s(network 3s), speed 824.39kB/s, json 79(198.21kB), tarball 2.55MB)
√ Installed 1 packages
√ Linked 0 latest versions
√ Run 0 scripts
√ All packages installed (used 122ms(network 117ms), speed 12.11kB/s, json 1(1.42kB), tarball 0B)

编辑_config.yml文件

在这里插入图片描述

拉到最下面
type修改类型
repo仓库地址
这些冒号后面都要留一个空格

在这里插入图片描述

进行部署

输入你创建账户时候的邮箱和名称

PS E:\blog> git config --global user.email "1667005299@qq.com"
PS E:\blog> git config --global user.name "subursts"

进行博客部署

PS E:\blog> hexo deploy

INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
warning: LF will be replaced by CRLF in 2020/09/20/hello-world/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in 2020/09/20/我的第一篇博客/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2020/09/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2020/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in css/style.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-media.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.pack.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/script.js.
The file will have its original line endings in your working directory
On branch master
nothing to commit, working tree clean
Username for 'https://gitee.com': sunbursts
Password for 'https://sunbursts@gitee.com':
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 12 threads
Compressing objects: 100% (37/37), done.
Writing objects: 100% (45/45), 507.58 KiB | 13.01 MiB/s, done.
Total 45 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/sunbursts/afu.git
 * [new branch]      HEAD -> master
Branch 'master' set up to track remote branch 'master' from 'https://gitee.com/sunbursts/afu.git'.
[32mINFO [39m Deploy done: [35mgit[39m

这里输入的用户名一定要是你创建的个人地址哪里的名字,不是昵称!!!!
踩了好久的雷

在这里插入图片描述

启动gitee pages部署服务

不启动这个博客会显示不全

在这里插入图片描述

在这里插入图片描述

查看博客

在这里插入图片描述

修改博客主题

在这里插入图片描述

vim _config.yml
找到theme把里面的landspace改成自己下载的
hexo clean
hexo  g
hexo s
hexo d

如果只能在本地查看到修改的页面,在gitee上看不到的话把仓库清空重新上传一下,然后重新部署一下gitee pages

博客插件

hexo-generator-searchdb 用于搜索

npm install hexo-generator-searchdb --save

然后将以下配置复制到你博客根目录下的 _config.yml 里(注意不是ayer目录下的):

COPY
# hexo-generator-searchdb
search:
  path: search.xml
  field: post
  format: html

hexo-generator-feed 用于生成RSS订阅

npm install hexo-generator-feed --save

然后将以下配置复制到你博客根目录下的 _config.yml 里(注意不是ayer目录下的):

feed:
    type: atom
    path: atom.xml
    limit: 20
    hub:
    content:
    content_limit: 140
    content_limit_delim: ' '
    order_by: -date	

hexo-tag-aplayer 用于播放音乐

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你想了解如何使用 Hexo 搭建个人博客,是吗?我可以为你提供一些基本的指导。首先,你需要按照以下步骤进行操作: 1. 安装Node.js:Hexo 是基于 Node.js 的静态网站生成器,所以你需要先安装 Node.js。你可以在 Node.js 官方网站上下载适合你操作系统的安装包,并按照指示进行安装。 2. 安装Hexo:打开命令行终端,运行以下命令来安装 Hexo: ``` npm install -g hexo-cli ``` 这将全局安装 Hexo 命令行工具。 3. 初始化博客:选择一个合适的目录作为你的博客根目录,并在终端中进入该目录。然后运行以下命令来初始化博客: ``` hexo init myblog cd myblog npm install ``` 这将创建一个名为 "myblog" 的新目录,并在其中初始化 Hexo。 4. 配置博客:在博客根目录中,找到名为 `_config.yml` 的文件,并使用文本编辑器打开它。在这个文件中,你可以配置博客的各种设置,比如标题、描述、作者等。根据你的需求进行相应的修改。 5. 创建新文章:使用以下命令来创建一个新的文章: ``` hexo new "My First Post" ``` 这将在 `source/_posts` 目录中创建一个名为 "my-first-post.md" 的 Markdown 文件。你可以使用 Markdown 语法来撰写文章内容。 6. 预览博客:运行以下命令来启动本地服务器,并预览你的博客: ``` hexo server ``` 然后在浏览器中访问 `http://localhost:4000`,你将看到你的博客的预览页面。 7. 部署博客:当你完成了博客的撰写和调试,可以使用以下命令来生成静态文件并部署到你的博客托管平台: ``` hexo generate hexo deploy ``` 这将生成一个名为 "public" 的目录,其中包含了你的博客的静态文件。你可以将这些文件上传到你选择的托管平台上,如 GitHub Pages、Netlify 等。 这些是使用 Hexo 搭建个人博客的基本步骤。当然,在实际使用过程中,你还可以根据需要安装主题、插件等来增强博客的功能和外观。希望这些信息对你有所帮助!如果你有任何进一步的问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值