将 jekyll 托管到 Google App 引擎

Hosting jekyll to Google App engine

使用 jekyll 建立了个人博客。一切都在本地主机上运行良好。我不想在 github 上部署它。出于某些原因,我更喜欢在 google 应用引擎上托管。

我按照一些在线说明将生成的 _site 文件夹复制到我的 google 应用引擎项目中。

这是 app.yaml 的样子:

application: myblog
version: 1
runtime: python27
api_version: 1
threadsafe: yes

error_handlers:
- file: /404.html

handlers:

- url: /
  static_files: _site/index.html
  upload: _site/index.html

- url: /(.*)
  static_files: _site/
  upload: _site/(.*)


libraries:
- name: webapp2
  version: "2.5.2"

当我 运行 在本地 google 应用程序引擎上时,仅显示 index.html 和一些其他文件。其他人显示找不到页面。有什么我没有正确实施的吗?

好吧,我终于弄明白了。反正是个小技巧

首先在您的 _config.yaml file 添加:

permalink:         /posts/:title/index.html

之后,运行 jekyll serve_site 文件夹中生成静态文件。将 post 文件夹复制到应用程序引擎项目中的 _site/。

然后,在您的 _config.yaml file 中将永久链接更改为:

permalink:         /posts/:title

运行 jekyll serve生成_site中的静态文件。将生成的整个文件 不包括 posts 文件夹复制到 _site/ 到您的应用程序引擎项目中。

然后,让您的应用引擎 app.yaml 看起来像这样:

application: myblog
version: 1
runtime: python27
api_version: 1
threadsafe: yes


handlers:
- url: /(.*\.js)
  mime_type: text/javascript
  static_files: _site/
  upload: _site/(.*\.js)

- url: /(.*\.(jpg|png|ico))
  static_files: _site/
  upload: _site/(.*\.img)

- url: /(.*\.css)
  mime_type: text/css
  static_files: _site/
  upload: _site/(.*\.css)

- url: /(.*\.(eot|svg|svgz|otf|ttf|woff|woff2))
  static_files: _site/
  upload: _site/(.*\.fonts)

- url: /
  static_files: _site/index.html
  upload: _site/index.html

- url: /(.+)/
  static_files: _site//index.html
  upload: _site/(.+)/index.html
  expiration: "15m"

- url: /(.+)
  static_files: _site//index.html
  upload: _site/(.+)/index.html
  expiration: "15m"

- url: /(.*)
  static_files: _site/
  upload: _site/(.*)

#- url: /((tags)|(archive)|(about)|(posts)|(fonts))/

libraries:
- name: webapp2
  version: "2.5.2"

详见 example