【解决】hexo 生成的publish中html都是空的?

往常新增文章之后,直接hexo d -g一键就发布了,然后去网站一看,啥也没有。就郁闷了。

因为目前https的证书也到期了,怀疑了好多点。

  1. nginx配置
    因为看页面的状态是302,怀疑是nginx的配置问题,之前https证书到期,需要把443的监听去掉,修改了一些配置,所以首度怀疑是配置问题。但配置就那几行,排除这个点。
  2. _config.yml配置文件
    网上很多说是_config.yml的配置问题,这个我确实改了一处,就是把avartar从https://media.lvxiang.site/file/avatar.jpeg改为了//media.lvxiang.site/file/avatar.jpeg,然后改回去,重新hexo clean & hexo d -gpublic中的html还是空的。
    PS:配置文件有问题可能会导致build失败
  3. hexo的版本
    又怀疑是hexo的版本问题,虽然都是3+,但不妨一试,使用了package中的3.7版本试了一下,还是不行 - -
  4. node版本
    接着运行hexo s --debug,然后打开网站,发现日志中有一些warning:
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

查了一下相关issue
然后nvm下了一个12+的版本,重新build,结果html有内容了!!!

证书到期了,懒得搞了,个人博客地址如下:
http://blog.lvxiang.site/

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
Node.js可以通过Hexo提供的API控制生成HTML。具体方法如下: 1. 在Hexo的根目录下创建一个JavaScript文件,例如`generate.js`。 2. 在`generate.js`引入Hexo模块: ```javascript const Hexo = require('hexo'); ``` 3. 创建一个新的Hexo实例: ```javascript const hexo = new Hexo(process.cwd(), {}); ``` 4. 调用Hexo的`init()`方法初始化Hexo实例: ```javascript hexo.init().then(function() { // Hexo实例初始化成功后的操作 }); ``` 5. 可以通过调用Hexo的`load()`方法加载Hexo的配置和插件: ```javascript hexo.load().then(function() { // Hexo配置和插件加载成功后的操作 }); ``` 6. 可以通过调用Hexo的`generate()`方法生成静态文件: ```javascript hexo.generate().then(function() { // 静态文件生成成功后的操作 }); ``` 7. 可以在生成静态文件的过程,通过Hexo的`extend.generator.register()`方法注册一个新的生成器,来控制生成HTML: ```javascript hexo.extend.generator.register('my-generator', function(locals) { // 生成器的具体实现,可以通过locals对象获取Hexo的数据 return { path: 'my-page.html', data: '<html><head><title>My Page</title></head><body><h1>Hello, World!</h1></body></html>' }; }); ``` 上述代码注册了一个名为`my-generator`的新生成器,该生成器会生成一个名为`my-page.html`的HTML文件,内容为`<html><head><title>My Page</title></head><body><h1>Hello, World!</h1></body></html>`。 8. 最后,可以通过调用Hexo的`exit()`方法退出Hexo实例: ```javascript hexo.exit(); ``` 以上就是通过Node.js控制Hexo生成HTML的基本方法。具体实现可以参考Hexo的官方文档。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值