How to show my posts in the first page and not in the “/blog” and maintaining other sub folders working like “/about” and “/projects”

泪湿孤枕 提交于 2019-12-23 12:18:13

问题


I'm trying to use Lektor as my blog platform, but I am running into a few issues.

Following the guide I can make everything work. My problem begin when I try to make the blog the first page, without the "/blog".

If I query in the page template the blogs children, the pagination don't work.

If I make the blog-post children of the page using "replaced_with = site.query('/blog')" the initial page renders fine, but if I try to access any page, appears a Not Found message.

My goal is show my posts in the first page and have other folders, like "/about" or "/projects" in the root folder.


回答1:


I get it! The way to do it was setting a query in the "items" key on the page model.

Like this:

[model]
name = Page
label = {{ this.title }}
hidden = yes
protected = yes

[fields.title]
label = Title
type = string

[pagination]
enabled = yes
per_page = 10
items = site.query('/blog')

After that it worked like a charm. :)




回答2:


I had same problem. I tried several thing and none of them worked.

I ended up doing page redirection. Lektor doesn't support redirects yet, they are working on it.

I created home.html so that it redirects to /blog.

<meta http-equiv="refresh" content="0; url=http://example.com/blog/" />

This is deprecated by WWC. Until lektor supports redirection, this the way to go.




回答3:


This is how I did it.

[model]
name = Blog
label = {{ this.title }}
hidden = yes

[fields.title]
label = Title
type = string

[children]
model = blog-post
order_by = -pub_date, title

[pagination]
enabled = yes
per_page = 5
items = this.children.filter(F._model == 'blog-post')


来源:https://stackoverflow.com/questions/37473790/how-to-show-my-posts-in-the-first-page-and-not-in-the-blog-and-maintaining-ot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!