300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 用hexo搭建个人博客

用hexo搭建个人博客

时间:2020-02-18 08:17:20

相关推荐

用hexo搭建个人博客

blog搭建

下载nodejs打开powershell检查nodejs版本安装hexo用npm安装cnpm安装hexo检查hexo版本 创建blog存放目录hexo初始化博客安装git初始化博客 启动博客新建一个博客文章生成静态文件启动创建gitee账户ssh 在blog目录下装git部署插件编辑_config.yml文件进行部署启动gitee pages部署服务查看博客修改博客主题博客插件hexo-generator-searchdb 用于搜索hexo-generator-feed 用于生成RSS订阅hexo-tag-aplayer 用于播放音乐

下载nodejs

官方网址:/en/

下载LTS版本的就可以

打开powershell

不是windows的打开终端输入命令 sudo su

以管理员身份运行

检查nodejs版本

C:\WINDOWS\system32>node -vv12.18.4C:\WINDOWS\system32>npm -v6.14.6

安装hexo

用npm安装cnpm

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

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

安装hexo

C:\WINDOWS\system32>cnpm install -g hexo-cliDownloading hexo-cli to C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli_tmpCopying 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-cliInstalling 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@resolveplatform 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-utilRecently updated (since -09-12): 3 packages (detail see file C:\Users\MECHREOV\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\.recently_updates.txt)-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 -vcnpm@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\npmwin32 x64 10.0.18363registry=https://r.C:\WINDOWS\system32>hexo -vhexo-cli: 4.2.0os: Windows_NT 10.0.18363 win32 x64node: 12.18.4v8: 7.8.279.23-node.39uv: 1.38.0zlib: 1.2.11brotli: 1.0.7ares: 1.16.0modules: 72nghttp2: 1.41.0napi: 6llhttp: 2.1.2http_parser: 2.9.3openssl: 1.1.1gcldr: 37.0icu: 67.1tz: cunicode: 13.0

创建blog存放目录

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

hexo初始化博客

安装git

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

git官方网址 :https://git-/download/win

这个是windows的,选择自己相对应的版本

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

初始化博客

首先要进入你创建好的目录下进行初始化

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

PS E:\blog> hexo initINFO Cloning hexo-starter /hexojs/hexo-starter.git[32mINFO [39m Install dependenciesadded 183 packages from 421 contributors and audited 189 packages in 15.106s10 packages are looking for fundingrun `npm fund` for detailsfound 0 vulnerabilitiesINFO Start blogging with Hexo!

查看生成了那些东西

PS E:\blog> ls目录: E:\blogModeLastWriteTime Length Name----------------- ------ ----d----- /9/:02node_modulesd----- /9/:01scaffoldsd----- /9/:01sourced----- /9/:01themes-a---- /9/:01 71 .gitignore-a---- /9/:0256414 package-lock.json-a---- /9/:01 602 package.json-a---- /9/:01 2545 _config.yml

启动博客

hexo s

s是server的简写

PS E:\blog> hexo sINFO Validating configINFO Start processingINFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

在本地的4000端口查看一下

新建一个博客文章

创建一篇博客文章

PS E:\blog> hexo new "我的第一篇博客"INFO Validating configINFO 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 cleanINFO Validating configINFO Deleted database.

生成静态文件

PS E:\blog> hexo generateINFO Validating configINFO Start processingINFO Files loaded in 727 msINFO Generated: archives/index.htmlINFO Generated: fancybox/blank.gifINFO Generated: archives//index.htmlINFO Generated: archives//09/index.htmlINFO Generated: index.htmlINFO Generated: fancybox/helpers/fancybox_buttons.pngINFO Generated: fancybox/fancybox_loading.gifINFO Generated: fancybox/fancybox_overlay.pngINFO Generated: fancybox/fancybox_sprite.pngINFO Generated: fancybox/fancybox_sprite@2x.pngINFO Generated: fancybox/fancybox_loading@2x.gifINFO Generated: js/script.jsINFO Generated: fancybox/helpers/jquery.fancybox-buttons.cssINFO Generated: fancybox/jquery.fancybox.cssINFO Generated: fancybox/helpers/jquery.fancybox-buttons.jsINFO Generated: fancybox/helpers/jquery.fancybox-thumbs.jsINFO Generated: fancybox/helpers/jquery.fancybox-media.jsINFO Generated: css/fonts/fontawesome-webfont.ttfINFO Generated: fancybox/helpers/jquery.fancybox-thumbs.cssINFO Generated: css/style.cssINFO Generated: css/fonts/fontawesome-webfont.woffINFO Generated: fancybox/jquery.fancybox.pack.jsINFO Generated: css/fonts/FontAwesome.otfINFO Generated: css/fonts/fontawesome-webfont.eotINFO Generated: /09/20/我的第一篇博客/index.htmlINFO Generated: fancybox/jquery.fancybox.jsINFO Generated: /09/20/hello-world/index.htmlINFO Generated: css/images/banner.jpgINFO Generated: css/fonts/fontawesome-webfont.svgINFO 29 files generated in 1.62 s

启动

生成以后在重新启动一下

就可以看到新建的博客了

PS E:\blog> hexo seINFO Validating configINFO Start processingINFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

创建gitee账户

设置个人地址

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

创建新仓库

ssh

PS E:\blog> ssh-keygen -t rsa -C “sunbursts@”

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@

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@

PS E:\blog> ssh -T git@The authenticity of host ' (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)? yesWarning: Permanently added ',180.97.125.228' (ECDSA) to the list of known hosts.Hi [36;01mafu[0m! You've [32msuccessfully[0m authenticated, but 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 scriptsRecently updated (since -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@"PS E:\blog> git config --global user.name "subursts"

进行博客部署

PS E:\blog> hexo deployINFO Validating configINFO Deploying: gitINFO Clearing .deploy_git folder...INFO Copying files from public folder...INFO Copying files from extend dirs...warning: LF will be replaced by CRLF in /09/20/hello-world/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in /09/20/我的第一篇博客/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//09/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives//index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in archives/index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in css/style.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-media.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/jquery.fancybox.css.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/jquery.fancybox.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in fancybox/jquery.fancybox.pack.js.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in index.html.The file will have its original line endings in your working directorywarning: LF will be replaced by CRLF in js/script.js.The file will have its original line endings in your working directoryOn branch masternothing to commit, working tree cleanUsername for '': sunburstsPassword for 'https://sunbursts@':Enumerating objects: 45, done.Counting objects: 100% (45/45), done.Delta compression using up to 12 threadsCompressing 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 0remote: Powered by [GNK-5.0]To /sunbursts/afu.git* [new branch]HEAD -> masterBranch 'master' set up to track remote branch 'master' from '/sunbursts/afu.git'.[32mINFO [39m Deploy done: [35mgit[39m

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

踩了好久的雷

启动gitee pages部署服务

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

查看博客

修改博客主题

vim _config.yml找到theme把里面的landspace改成自己下载的hexo cleanhexo ghexo shexo d

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

博客插件

hexo-generator-searchdb 用于搜索

npm install hexo-generator-searchdb --save

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

COPY# hexo-generator-searchdbsearch:path: search.xmlfield: postformat: html

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

npm install hexo-generator-feed --save

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

feed:type: atompath: atom.xmllimit: 20hub:content:content_limit: 140content_limit_delim: ' 'order_by: -date

hexo-tag-aplayer 用于播放音乐

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。