東川印記

一本東川,笑看爭龍斗虎;寰茫兦者,度橫佰昧人生。

基于github pages搭建hexo网站

2022年4月6日星期三



老技术了,临时需要拿出来晒晒。。。。

先注册邮箱,拿邮箱注册github,github 注册repo,repo名格式为 网站前缀.github.io

SENRSL:temp senrsl$ npm install hexo-cli -g

added 60 packages, and audited 61 packages in 9s

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

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 8.1.0 -> 8.6.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.6.0
npm notice Run npm install -g npm@8.6.0 to update!
npm notice
SENRSL:temp senrsl$  hexo version
hexo-cli: 4.3.0
os: darwin 21.3.0 12.2.1

node: 16.13.0
v8: 9.4.146.19-node.13
uv: 1.42.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.17.2
modules: 93
nghttp2: 1.45.1
napi: 8
llhttp: 6.0.4
openssl: 1.1.1l+quic
cldr: 39.0
icu: 69.1
tz: 2021a
unicode: 13.0
ngtcp2: 0.1.0-DEV
nghttp3: 0.1.0-DEV
SENRSL:temp senrsl$ mkdir zhongliangweiquan
SENRSL:temp senrsl$ cd zhongliangweiquan/
SENRSL:zhongliangweiquan senrsl$ npm install hexo-deployer-git --save

added 54 packages, and audited 55 packages in 2s

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

found 0 vulnerabilities
SENRSL:zhongliangweiquan senrsl$ hexo init website
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO  Install dependencies
INFO  Start blogging with Hexo!
SENRSL:zhongliangweiquan senrsl$ cd website/
SENRSL:website senrsl$ npm install

added 1 package, and audited 249 packages in 1s

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

found 0 vulnerabilities
SENRSL:website senrsl$

其中,website才是真正的网站库,外面的是因为要存放

上面是旧版本的,新版本直接

SENRSL:temp senrsl$ npm install hexo-cli -g

added 60 packages, and audited 61 packages in 9s

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

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 8.1.0 -> 8.6.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.6.0
npm notice Run npm install -g npm@8.6.0 to update!
npm notice
SENRSL:temp senrsl$  hexo version
SENRSL:temp senrsl$ hexo init zhongliangweiquan
INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO  Install dependencies
INFO  Start blogging with Hexo!
SENRSL:temp senrsl$ cd zhongliangweiquan/
SENRSL:zhongliangweiquan senrsl$ hexo server
INFO  Validating config
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
(node:43885) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:43885) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:43885) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:43885) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:43885) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:43885) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
INFO  Have a nice day
SENRSL:zhongliangweiquan senrsl$

即可,非常简单。。。。

目录

SENRSL:zhongliangweiquan senrsl$ tree -L 1
.
├── _config.landscape.yml
├── _config.yml
├── db.json
├── node_modules
├── package-lock.json
├── package.json
├── scaffolds
├── source
└── themes

4 directories, 5 files
SENRSL:zhongliangweiquan senrsl$

配置在 https://hexo.io/zh-cn/docs/configuration

遇到一个历史遗留问题,研究了三四个小时,屮

之前本机已经配置了github ssh,现在又新建了github ssh账号,结果就变成了用旧的ssh去提新项目,鉴权就失败了。。。。

SENRSL:Downloads senrsl$ ssh -T zhongliang
Hi zhongliangweiquan! You've successfully authenticated, but GitHub does not provide shell access.
SENRSL:Downloads senrsl$ ssh -T github.com
Hi kdsrsl! You've successfully authenticated, but GitHub does not provide shell access.
SENRSL:Downloads senrsl$
SENRSL:Downloads senrsl$ cat ~/.ssh/config
Host bitbucket.org
Hostname  altssh.bitbucket.org
Port  443

Host *
    ServerAliveInterval 60

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa

Host zhongliang
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_zhongliang
SENRSL:Downloads senrsl$

老问题,回炉造。。。。

然后自定义Host的地址,需要把库的路径也改掉,即 github.com -> zhongliang

SENRSL:zhongliangweiquan.github.io senrsl$ git remote -v
origin    git@github.com:zhongliangweiquan/zhongliangweiquan.github.io.git (fetch)
origin    git@github.com:zhongliangweiquan/zhongliangweiquan.github.io.git (push)
SENRSL:zhongliangweiquan.github.io senrsl$ git remote set-url origin git@zhongliang:zhongliangweiquan/zhongliangweiquan.github.io.git
SENRSL:zhongliangweiquan.github.io senrsl$ git push
Everything up-to-date
SENRSL:zhongliangweiquan.github.io senrsl$

终于提交成功了。。。。。。


按照hexo官网连接了 travis ci,发现不运行。。。。然后发现,必须要先验证email,然后需要填信用卡信息,free套餐也要填信用卡信息,而且所谓的free只是有限的free,过了指定次数后就不free了。。。。。


修改主题

git clone https://github.com/theme-next/hexo-theme-next themes/next

然后修改 _config.yaml中theme为next

重新部署运行

SENRSL:zhongliangweiquan senrsl$ hexo d -g

SENRSL:zhongliangweiquan senrsl$ hexo server


生成sitemap

SENRSL:zhongliangweiquan senrsl$ npm install hexo-generator-sitemap --save

SENRSL:zhongliangweiquan senrsl$ npm install hexo-generator-baidu-sitemap --save

SENRSL:zhongliangweiquan senrsl$ hexo d -g

sitemap生成在public目录

图片资源

根config.yaml改post_asset_folder: true

SENRSL:zhongliangweiquan senrsl$ npm install hexo-asset-image --save

up to date, audited 514 packages in 6s

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

19 vulnerabilities (2 low, 9 moderate, 7 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
SENRSL:zhongliangweiquan senrsl$ hexo new "配套学校宣传"
INFO  Validating config
INFO  Created: ~/temp/zhongliangweiquan/source/_posts/配套学校宣传.md
SENRSL:zhongliangweiquan senrsl$ hexo d -g

md内正常引用即可  ![](./配套学校宣传/家门口的学府宣传.JPG)

本地可以了,但是推到 Travis就不行。。。。

找了一遭,竟然是 文件后缀变了,jpg变成了 JPG。。。。


底部改了icon不显示

需要注意版本,提示的那个网站,版本高,hexo支持的版本低。。。。


--
senRsl
2022年04月03日15:29:17

没有评论 :

发表评论