Dam*_*ien 1 self-hosting handlebars.js ghost-blog
我刚刚建立了一个幽灵博客。这是VPS 上的全新安装,并且已正确启动并运行。
默认情况下,Ghost在浏览器中打开时会显示帖子列表。我希望在该位置有一个主页/,并且可以在/blog. 据我所知,这可以通过使用Dynamic Routing来实现。
为了简化这一点,我想我可以page(Ghost 有页面和帖子的概念)作为主页。然后我可以使用已经存在的page.hbs模板呈现这个页面。
这是我的routes.yaml文件:
routes:
/:
data: page.home
template:
- page
collections:
/blog/:
permalink: /blog/{slug}/
template:
- index
taxonomies:
tag: /blog/tag/{slug}/
author: /blog/author/{slug}/
Run Code Online (Sandbox Code Playgroud)
我有一个名为home的页面,但是当我加载主页时,我得到一个空页面:只显示页脚。
日志中没有提示告诉我可能发生什么。我理解routes.yaml正确吗?是page.home不是如何向页面传递数据?
我在forum.ghost.org上问了这个问题,并得到了我想要的答案。
解决方案是使用长格式数据表示法,如下所示。我的routes.yaml文件现在看起来像:
routes:
/:
data:
post: page.home
template: page
collections:
/blog/:
permalink: /blog/{slug}/
template:
- index
taxonomies:
tag: /blog/tag/{slug}/
author: /blog/author/{slug}/
Run Code Online (Sandbox Code Playgroud)
现在,当我加载example.com 时,page 主页已加载,当我导航到example.com/blog 时,博客已加载