Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata for custom page ordering #420

Closed
onlyhavecans opened this issue Jul 15, 2012 · 12 comments
Closed

Add metadata for custom page ordering #420

onlyhavecans opened this issue Jul 15, 2012 · 12 comments
Assignees

Comments

@onlyhavecans
Copy link
Contributor

raignarok in IRC gave me this idea for this feature so I am documenting it.

  • A :page-order: # metadata for pages
  • Any page-order metadata that doesn't cast properly to a number throws a warning and discards the metadata
  • Pages with the page-order metadata go first in the list, sorted in ascending numerically.
  • If there is multiple pages with the same order # then they will be sorted by alpha slug
  • Any pages missing an order # goes at the end of the list alpha-slug just like before to keep compatibility.

This will probably go nicely with #400 and #220 since pages and the location of articles will be way more flexible.

@ghost ghost assigned onlyhavecans Jul 15, 2012
@almet
Copy link
Member

almet commented Jul 15, 2012

+1 :)

@onlyhavecans
Copy link
Contributor Author

Ok! Its on my todo list

@almet
Copy link
Member

almet commented Oct 25, 2012

Included for 3.1

@Stiivi
Copy link

Stiivi commented Jan 23, 2013

+1 - would be lovely to have this feature as well as already mentioned #400 ad #200. Very helpful for project sites or sites of ogrganisations.

@justinmayer
Copy link
Member

@tbunnyman: Do you think you can find some time to work on this issue? Just trying to plan the next release. 😄

@davidmarble
Copy link
Contributor

I've just added a pull request with a fix.

This change makes the default sorting order for pages their filenames (new). The default sorting order for articles is still by slug (same as before). But you can tweak how either is sorted in your pelicanconf.py. For example:

PAGE_ORDER_BY = 'page-order'

In this case, just make sure that all pages have the metadata attribute 'page-order'.

Advanced: You could also use a sorting function. See the code for an example, as a sorting function is used to get filenames based on the source_path attribute of content.

@davidmarble
Copy link
Contributor

This new pull request seems to do it. Hopefully it's accepted.

@ssbarnea
Copy link

This interest me and when I will have a little time I may rework this. Still, I would like to propose a slightly different implementation:

  • meta attribute to be called "order" so it is identical for articles too.
  • if is positive pages will be sorted on top based on the same logic, bug if is negative it will sort them after those with no order specific. This would enable you to put a page to the bottom.

@vjousse
Copy link
Contributor

vjousse commented May 14, 2014

I've merged @davidmarble work and @malept tests against current master in #1348

Works like a charm for me.

@justinmayer
Copy link
Member

Feature merged and will be included in Pelican 3.5. Thanks to everyone for their input, contributions, and patience.

@arqeco
Copy link

arqeco commented Jun 7, 2015

It may sounds exaggerated, but this is a HUGE improvement to non-blog site projects in Pelican. This feature deserves a better explanation in the docs, maybe a full paragraph. Thank you very much!

@newptcai
Copy link

newptcai commented Dec 3, 2018

I gave this a try and it didn't work! Then I realized that is because the template which I am using also sort the pages!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment