strug
December 28, 2020, 8:59pm
1
Hi
how can I configure the layout of the posts?
If I look at demo.ghost.io the blog posts have a much more dynamic layout (pic: ghost-casper-demo) than running ghost local (pic: ghost-casper-local).
How and where is this managed?
Thanks a lot, Best Leif
PS: I’m using Ghost version: 3.40.1 and Casper 3.1.2
When you say “much more dynamic layout” can you elaborate ?
If you want to change your layout, you need to modify the theme. If it’s something you are not comfortable to code, I would buy one out of the shelf.
strug
December 29, 2020, 6:14pm
3
What I mean is, in the first screenshot you see that the layout is
1 post
3 posts
2 posts
1 post
3 posts
2 posts
I use the same theme but my layout of the posts is
3 posts
3 posts
1 post
I’m asking myself where and how is this configured. How can I get a “1-3-2” layout of posts?
Thanks, Leif
Hey @strug , the main logic is in the first line of partials/post-card.hbs
file.
It says every sixth post to have a class post-card-large
with {{#has index="nth:x"}}
helper.
<article class="post-card {{post_class}} {{#unless feature_image}}no-image{{else}}{{#is "home"}}{{#has index="nth:6"}}post-card-large{{/has}}{{/is}}{{/unless}}">
{{#if feature_image}}
<a class="post-card-image-link" href="{{url}}">
{{!-- This is a responsive image, it loads different sizes depending on device
https://medium.freecodecamp.org/a-guide-to-responsive-images-with-ready-to-use-templates-c400bd65c433 --}}
<img class="post-card-image"
srcset="{{img_url feature_image size="s"}} 300w,
{{img_url feature_image size="m"}} 600w,
{{img_url feature_image size="l"}} 1000w,
{{img_url feature_image size="xl"}} 2000w"
strug
January 6, 2021, 8:36am
6
Perfect. Found it. Cool. Thanks a lot!
strug
January 6, 2021, 8:43am
7
Then https://demo.ghost.io/ seems to run a modified default theme of GitHub - TryGhost/Casper: The default theme for Ghost , because there the posts are structured 1-3-2-1-3-2…
strug
January 9, 2021, 8:05pm
8
@minimaluminium can you tell me where to find to caspar theme source which runs the demo at http://demo.ghost.io/ ? In the 1st screenshot above you see the order 1, 3, 2, 1, 3, 2 posts per row. I checked the default caspar theme and there is only a post-card
and a post-card-large
style. Would be create if I don’t need to fiddle to get a post-card-medium
displaying 2 posts in a row, when someone from you already created that. Thanks, Leif
Hey @strug , https://demo.ghost.io/ runs the exact same version of TryGhost/Casper . This is how the layout looks on a fresh local Ghost instance which is also same as the demo.
If you posted your live site URL which had an issue with the post layout, people might be able to help you.
strug
January 11, 2021, 8:39pm
10
you’re right. but as soon as I change the route.yaml to the one below, the layout/ordering is 1-3-3-1-3-3… instead of 1-3-2-1-3-2…
Do you have any idea why?
routes:
/:
data: page.home
template: home
collections:
/usecases/:
permalink: /usecases/{slug}/
template: usecases
filter: primary_tag:usecase
data: tag.usecase
/blog/:
permalink: /blog/{slug}/
template: index
filter: tag:-landingpage+tag:-usecase
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
strug
January 13, 2021, 9:16pm
11
@minimaluminium is this a bug or intended?
You’re using home.hbs
template as your homepage. Is this a copy of index.hbs
, or something custom?
strug
January 14, 2021, 10:43am
13
home is different, but /blog
is using index.hbs
, so I expected that the layout of <site>/blog/
should behave like <site>/
from a clean installation.
/blog/:
permalink: /blog/{slug}/
template: index
filter: tag:-landingpage+tag:-usecase
You’re right, I totally missed that. In this case, the important part is:
{{#is "home"}}{{#has index="nth:6"}}post-card-large{{/has}}{{/is}}
This checks if it’s the homepage and only applies the CSS class when it’s on the homepage. That’s why the class isn’t getting applied on your custom blog page.
strug
January 28, 2021, 9:23pm
15
Perfect,
removing {{#is "home"}}
in the first line of post-card.hbs
gives me the same default layout of posts under /blog
. Thank you @minimaluminium .
<article class="post-card {{post_class}} {{#unless feature_image}}no-image{{else}}{{#has index="nth:6"}}post-card-large{{/has}}{{/unless}}">