Skip to content

Article Weights Explained

The basic behavior of any list of article is to order everything by reverse publication time. Functionally, that means that newer things will always appear above older things.

But what if you have stories that need to be featured in prominent places, even after new content has been published?

Weights

Weights have been a feature of CEO from the beginning, but aren't understood very well. Weights allow you to have more direct control over the order in which stories appear on any given page.

In most cases, CEO orders stories by weight first, then publication date. So, giving a story a higher weight will force it to appear higher in the list. The default weight is 0, the highest weight is 5.

For example, let's say we have two stories:

Title Published Date Weight
Alice wins angling trophy 2022-10-31 15:30:00 0
Bob bakes pies 2022-11-01 00:00:00 0

Because Bob was published after Alice, Bob will always appear before Alice. If we want Alice to appear first, we just need to change the weight:

Title Published Date Weight
Alice wins angling trophy 2022-10-31 15:30:00 1
Bob bakes pies 2022-11-01 00:00:00 0

Now, with a weight of 1, Alice will appear above Bob. So, now our order is:

  • Alice
  • Bob

Now, let's add another story:

Title Published Date Weight
Alice wins angling trophy 2022-10-31 15:30:00 1
Bob bakes pies 2022-11-01 00:00:00 0
Charlie's chin up record 2022-11-01 00:00:00 0

Charlie was published at the same time as Bob, but since it's "newer," it'll appear above Bob. Our order now is:

  • Alice
  • Charlie
  • Bob

We want the order to be Alice, Bob, Charlie, so we set the weights accordingly:

Title Published Date Weight
Alice wins angling trophy 2022-10-31 15:30:00 2
Bob bakes pies 2022-11-01 00:00:00 1
Charlie's chin up record 2022-11-01 00:00:00 0

So, our final order is:

  • Alice
  • Bob
  • Charlie

Dead weight

This is all great, but over time it can lead to issues, like:

"Why doesn't this story ever go away?!?!?!?!"

Well, to deal with that, weights in CEO decay over time, following this formula:

Weight will decay by 1 point every 24 hours IF the story is MORE THAN 24 hours old.

That means a story that you just set to 5, won't drop to 4 until it's at least a day old. That also means everything decays together, 5 to 4, 4 to 3 and so on until they reach 0, so the relative weight of each item remains consistent.