Skip to content

Pin a post to keep it at the top

#48

Some posts should be the first thing a new reader sees: an introduction, the index of a series, a note on what the blog is about. Repozine can now keep them there. Pin the post on GitHub, and the home page lists it first.

How to pin

Open the post on GitHub and choose Pin discussion (or Pin issue in issues mode) in the right sidebar. Pinning and unpinning rebuild the site, just like editing or labeling a post. Unpin it, and it goes back to its place by date.

This post is a live example. It is newer than Repozine: your repository is already a blog, but that one is pinned, so it stays above this one on the home page with a Pinned chip.

What moves and what doesn't

  • Only the home page lifts pinned posts. Tag pages, search, the RSS feed and the newer/older links under each post stay in date order.
  • Pinned posts are sorted newest first among themselves.
  • GitHub allows 3 pinned issues and 4 pinned discussions per repository, so they always fit on the first page.
  • Only pins at the top of the Discussions page count. Pinning a discussion to a single category isn't available through GitHub's API, so Repozine can't see it.
  • A pin only matters for a post the site publishes: your own, still open, and in the configured category.

Updating an existing site

If you added Repozine to an existing repository, the rebuild workflow on your default branch needs two more event types, pinned and unpinned:

on:
  issues:
    types: [opened, edited, deleted, closed, reopened, labeled, unlabeled, transferred, pinned, unpinned]
  discussion:
    types: [created, edited, deleted, transferred, category_changed, labeled, unlabeled, pinned, unpinned]

The rest of the file stays the same. See the README for the whole workflow.

Thanks for the suggestion in issue #47.