appernetic / hugo-nederburg-theme

Nederburg is a fast and secure hugo theme and is a port of the Tracks WP theme
Other
106 stars 86 forks source link

Home Page Post Order #44

Closed MatthewMcD closed 5 years ago

MatthewMcD commented 5 years ago

It might be "just me" but I am seeing that the posts on the home page do not sort in date order.

I am at a loss for how to change the sort order to fix it. Ideally we could add a token to the config file.

andretti1977 commented 5 years ago

I see the posts correctly ordered by date descending. See my customization: devamountain.com

MatthewMcD commented 5 years ago

Did you make any changes? Your repo says it's up to date with appernetic:master. If you did can you push the branch?

andretti1977 commented 5 years ago

My site repo is not the one you see forked on github account. I did customizations to the theme, but didn't change anything related to page ordering so it should work for you too.

MatthewMcD commented 5 years ago

So...it's me. :) I'll have a look.

MatthewMcD commented 5 years ago

I just retested with a fresh clone and used the sample site (which we should update the sample posts to have different dates). It lists them in "file order".

MatthewMcD commented 5 years ago

@andretti1977 can you check your portfolio.html page? I found that adding .ByDate.Reverse to the range paginator solved the problem. The question is: Should this be the default behavior or should it be optional and configured in the config.toml file? @appernetic Thoughts?

I'll submit a PR that includes this and updates to the work files so that they have different dates and categories and tags.

andretti1977 commented 5 years ago

That's strange: i've just tried on my local istance changing the date of the second post and it is shown in the correct order (see the picture below where welcome post is the most recent one and compare it with the online istance where welcome post is the oldest). Just consider i have this format date in front matter section: date = "Thu Aug 25 10:00:00 CEST 2018"

image

MatthewMcD commented 5 years ago

Have you tried it with the sample site and the sample content work#.md files? That was my test. The date format is date = "2015-04-11T18:25:22+05:30"

andretti1977 commented 5 years ago

It may be an issue with date format? Can you try setting date in the same format i suggested to you and verify if it works?

MatthewMcD commented 5 years ago

What date format is that? I am using this date converter to go from the W3C format in the samples.

andretti1977 commented 5 years ago

I must be honest with you, i can't find the source of that format! I found it on some hugo post examples online but can't address the source anymore. Have you tried with that format? Does it work for you?

MatthewMcD commented 5 years ago

I can't explain it, but it does not work for me using the following dates in order from work1-11: date = "Sat Apr 11 12:55:00 CEST 2015" date = "Sat Nov 05 09:11:00 CEST 2016" date = "Wed Sep 05 09:14:00 CEST 2018" date = "Sat Nov 05 09:09:00 CEST 2016" date = "Sat Nov 05 08:15:00 CEST 2016" date = "Sun Oct 08 09:24:00 CEST 2017" date = "Sat Nov 05 09:29:00 CEST 2016" date = "Fri May 16 09:00:00 CEST 2014" date = "Sat Feb 14 08:52:00 CEST 2015" date = "Sat Oct 7 01:00:00 CEST 2017"

I get the following result (I added the year to the slug for clarity). image

Adding .ByDate.Reverse to portfolio.html forces the correct order. image

Hugo should be converting the date string in the front matter to a date before sorting. So the format should have no bearing on the order.

Edit: I even screwed up and used a different format for one of the dates and the sort order works fine now.

andretti1977 commented 5 years ago

Sorry but i don't know what to say...i just added to local server a new post and played with date and it worked correctly. This is a sample front matter (added a custom param):

+++
showonlyimage = true
draft = false
image = "img/mika-luoma-660672-unsplash.jpg"
date = "Thu Sep 25 10:00:00 CEST 2018"
title = "Create and host a static site for free"
categories = [ "entrepreneurship"]
tags = ["business development", "developer"]
weight = 1
image_caption = "<a href='https://unsplash.com/photos/9pI8YM99hhY' target='_blank'>Photo by Mika Luoma on Unsplash</a>"
+++
MatthewMcD commented 5 years ago

What happens when you start from a fresh site and then clone the repo into your site? That is how I have been testing. (Rather than using your front matter.)

appernetic commented 5 years ago

Strange. But .ByDate.Reverse is a good fix, and I think that it should be a default behaviour, it's a blog.