将 jekyll 托管到 Google App 引擎

Nos*_*lvi 5 google-app-engine jekyll

使用jekyll建立了个人博客。一切在本地主机上运行良好。我不想将其部署在 github 上。由于某些原因,我更喜欢托管在谷歌应用程序引擎上。

我按照网上的一些说明并将生成的 _site 文件夹复制到我的谷歌应用程序引擎项目中。

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/\1
  upload: _site/(.*)


libraries:
- name: webapp2
  version: "2.5.2"
Run Code Online (Sandbox Code Playgroud)

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

Nos*_*lvi 1

嗯,我终于弄清楚了。无论如何,这也是一个小技巧。

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

permalink:         /posts/:title/index.html
Run Code Online (Sandbox Code Playgroud)

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

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

permalink:         /posts/:title
Run Code Online (Sandbox Code Playgroud)

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

然后,让你的 appengine app.yaml 看起来像这样:

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


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

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

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

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

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

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

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

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

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

libraries:
- name: webapp2
  version: "2.5.2"
Run Code Online (Sandbox Code Playgroud)

请参阅示例以进行说明