Show first 1 post (not page) that is not in specific category

Hello everyone.

I have a homepage (/layouts/index.html) where I wanna show the latest post, ignoring posts that is in specific category.
I tried do that:

{{range first 1 (where .Pages ".Params.categories" "!=" "my-ignored-category") }}
  {{ .Title }}
{{end}}

But this show a Page instead a the latest post. Exist a way where can I show only Type post?

Assuming your posts are called “posts,” try something like this:

{{range first 1 (where (where .Data.Pages "Section" "posts") ".Params.categories" "!=" "my-ignored-category") }}
1 Like

How can I order this list?
I don’t know why, but when I call this code, the posts that was showed is different of when I call {{range first 1 .Pages}}. I think that because the order.

I think it should sort by date by default. Without seeing your code I can’t say anything definitive, but to add a sorting parameter (again, I don’t think you should have to do this), just keep on nesting.

{{ range first 1 (sort (where (where .Data.Pages "Section" "posts") ".Params.categories" "!=" "my-ignored-category") ".Date" "desc") }}

I’m also not sure you need the outer paren, but for clarity, I’m adding them there.