【问题标题】:Why Is My Github Pages Custom Domain Constantly Reset?为什么我的 Github 页面自定义域会不断重置?
【发布时间】:2021-10-01 19:11:53
【问题描述】:
【问题讨论】:
标签:
github
web-deployment
github-pages
【解决方案1】:
gh-pages npm 包的 repo 中似乎有关于此的报告。见#347、#236、#370、#213。
甚至还有一个still opened merged pull-request 可以通过文档解决这个问题。
基本上,它说:
如果您使用自定义域,请将部署行修改为您的部署脚本。这将阻止部署从 github 的设置中删除域。
echo 'your_cutom_domain.online' > ./build/CNAME && gh-pages -d build"
编辑:还有其他选项,有些人直接更改他们的部署调用并将自定义域添加到他们的部署脚本中:
var ghpages = require('gh-pages');
var fs = require('fs');
fs.writeFile('dist/CNAME', "your-custom-domain.com", function(err) {});
ghpages.publish('dist', function(err) {});
其他人只需按照建议将CNAME 放入您的发布文件夹即可。