【问题标题】:Hosting jekyll to Google App engine将 jekyll 托管到 Google App 引擎
【发布时间】:2016-09-04 13:55:59
【问题描述】:

使用 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"

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

【问题讨论】:

  • 顺便说一句,如果它只是一个静态网站,将它部署到存储更容易。如果是这个原因,您可以为存储桶分配域名

标签: google-app-engine jekyll


【解决方案1】:

好吧,我终于弄明白了。无论如何,这是一个小技巧。

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

permalink:         /posts/:title/index.html

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

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

permalink:         /posts/:title

运行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"

请参阅example 了解详情

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    相关资源
    最近更新 更多