2016-09-04 26 views
4

使用jekyll构建个人博客。在本地主机上一切正常。我不想在github上部署它。出于某些原因,我更愿意在Google应用引擎上托管。托管jekyll Google App引擎

我跟随了一些在线指令,并将生成的_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和其他一些文件显示。其他人显示未找到页面。有什么我没有正确实施?

+1

顺便说一句,如果它只是一个静态的网站,很容易将其部署到存储。您可以将一个域名分配给一个存储桶,如果是这样的话 –

回答

1

那么,我终于搞清楚了。无论如何,这是一个小窍门。

首先在_config.yaml file加:

permalink:   /posts/:title/index.html 

后,运行jekyll serve生成静态文件夹_site。将帖子文件夹复制到您的应用引擎项目中的_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澄清