Sunday, August 18, 2024

Tailored blog feeds

Antique sewing machine
photo: pexels

The insight that your blog is a database unlocks special blog pages tailored to combine subtopics.

Not just a page showing all the posts you've labeled "bread" (an old trick, and a handy one), but a page combining posts with two labels ("bread" plus "cheese").

Or, a page restricted to posts bearing both labels ("bread" and "cheese"). Or one that excludes (all "bread," except if also "cheese").

Well, you can do the same things with your blog feed.

Tailored feeds

Hat tip to Sam Nordberg, who posted about the "exclude" case ("not A" etc.) on his blog, 10원 Tips. Check it out!

The basic form of the Blogger feed search url is

[blog url]/feeds/posts/default?q=[term1][operator][term2][operator][term3] etc.

Term1 etc. refers to the search term, which can be a word, a phrase, or a label.

  • All posts with a word: ?q=cheddar
  • All posts with a phrase: ?q="rye bread" (phrases must be in quotes)
  • All posts with a label: ?q=label:cheese

Operator refers to the logical (Boolean) operators AND, OR, and NOT (and AND NOT).

  • AND uses the plus sign +. It finds posts that have both search terms, A and B.
  • OR uses the "pipe" character |. It finds posts that have either A or B (or both).
  • NOT uses the minus sign -. It excludes A from the universe of all posts ("not A").
  • AND NOT +- excludes B and subsequent posts ("and not B").
You can combine these.

Specific examples of tailored feeds, with more explanation, to come are in links below.

Update: How to do AND.

Further update: How to do OR.

Still further update: How to do NOT

Optional parameters

Sam recommends adding the "by-date=true" parameter, to show the most recent posts first.

This makes sense if you are creating a tailored feed to follow in a feed reader. It may not matter for scripts, but does no harm.

But note that only the first parameter in the url begins with a question mark. Subsequent parameters must begin with an ampersand.

So, for instance, ?by-date=true&q=label:feeds.

It may also be advisable to add the "max-results=150" parameter to the end of this feed url. Without that, Blogger caps the feed at 25 elements.

Remember, the feed is dynamic, so may grow to be longer than 25 items even if it is shorter than that today.

Why feeds?

Your blog has a feed (many, actually, unless you have disabled them), which are a kind of coded broadcast of your blog. Anyone can follow a feed in a feed reader.

You can also use feeds to create automated lists of blog posts by topic. You use a blog feed for the subscribe-by-email option, should you choose to set that up.

Raw feeds comprise a lot of code designed to be read by software, not you. The software translates the feed into user-friendly text, images, and hyperlinks.

Some feed readers will not, unfortunately, recognize the complex feeds described in this report, but some will.

Fussy feeds

The form of these feed urls is unforgiving. They won't work if you make even a small error typing them. If you have a problem building one of these feeds, check your work carefully.

For instance, the label names are case sensitive. A search query for "Feeds" will find nothing on this blog, because the label is "feeds."

Feed notes

Feed-savvy readers may note that these searches operate on the main blog feed of all posts:
  • too-clever-by-half.blogspot.com/feeds/posts/default

and not any of the specific label feeds such as

  • too-clever-by-half.blogspot.com/feeds/posts/default/-/feeds

which is the label feed for posts in this blog labeled "feeds."

You can do for feeds what my previous "database superpowers" series describes for blog posts.

Namely, combine and exclude posts from a feed.

Use this technique to subscribe to a curated subset of posts, such all my posts about changes to feeds, or to create a dynamic list of posts that updates itself.

These urls are fussy to build, but they describe a feed that, once specified, revises itself automatically.

Add or remove blog posts from the feed by adding or removing labels or search terms, not by editing the feed url.

Summary

  • Use this formula to build a tailored feed:

[blog url]/feeds/posts/default?q=[term1][operator][term2][operator][term3] etc.

  • Specific examples in links below.

Logical ANDLogical ORLogical NOT • About feeds
Dynamic listsTailored pages

4 comments:

  1. How can I show only the Articles feed in RSS? Without showing comments and RSS 2.0 feed

    ReplyDelete
    Replies
    1. The blog feed for posts (articles), used here, does not show comments.

      Delete
  2. Thanks for the shoutout. This has really helped on certain blogs that post a glut of content on specific topics that I have zero interest in (looking at you, US Politics). Filter out that junk and just get all other posts. Wordpress lets you do this too. Which just goes to show the joyful power of RSS.

    ReplyDelete
    Replies
    1. Thank you, Sam. This really fells like a slo-mo, long-distance, impromptu collaboration.

      I'm exploring all the Boolean possibilities, but as a practical matter I suspect that the filtering of "junk" is the only likely use case for this.

      Delete