是否有一种自动化的方式来轻松托管由 wintersmith 制作的静态站点在 Github Pages 或 Heroku 上?
我尝试编写一个 gruntfile、shell 脚本以及此 issue 中提到的一些建议。但所有这些都很难设置。
我基本上正在寻找像这样简单的东西 -
wintersmith new myblog
npm install
wintersmith deploy
PS: 有人可以给这个问题贴上新的冬日史密斯标签吗?
最佳答案
以下是一些基于我的 github 页面设置的一般指南。 (more info on github pages)
我有两个文件夹。一个用于 Wintersmith,另一个是 git 存储库文件夹。
./myblog/ (wintersmith)
./personalblog/ (git repo)
在配置 git 存储库时,通过以下方式创建 ./personalblog/
:
mkdir personalblog; cd personalblog
git init
git branch -m master gh-pages (this is important! see: https://help.github.com/articles/user-organization-and-project-pages#project-pages)
在 github 上创建同名存储库。然后设置本地仓库的来源。 See here for more info.
在 ./myblog
中,我有一个 bash 脚本 (build.sh),其中包含以下内容:
#!/bin/sh
# ./myblog/build.sh
# other build commands such as javascript or css minifiers
rm -r ./build/
wintersmith build
然后,我检查并验证 Wintersmith 的构建。我使用 nodejs http-server 进行验证。我还有另一个用于部署的 bash 脚本文件:
#!/bin/sh
# ./myblog/deploy.sh
# rsync to efficiently sync ./myblog/build to ./personalblog/
# ignore deleteing .git folder and other stuff
rsync -rtvu --delete -f"- .git/" -f"- CNAME" -f"- .gitignore" -f"- README.md" ./build/ ../personalblog/
# change dir
cd ../personalblog/
# sync to github
git add -A
git commit -am "Commit on $(date)"
git push origin gh-pages
希望这些指南对您有所帮助。
关于node.js - 对 Wintersmith 中部署的开箱即用支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18762081/