[solved] Newsletter directory, what am I doing wrong?

I’m following these instructions to add a newsletter directory:

Objective: working banner and list of emails sent out underneath it.

Trying to implement a newsletter archive page similar to

But I’m failing miserably as find inconsistencies should I change routes.yaml in the theme (Lyra) vs changing the content > settings > routes.yaml.

How to reproduce:

Add the following to Lyra specific routes.yaml (under collections)

  /newsletter/:
            permalink: /{slug}/
            template: index

And you get this:

The cool thing is that those two “emails” are actually emails that were successfully sent out, so that part of my objective is working.

Issue: the header banner does not work and I get a 404 error.

Now, should I, instead, add the same to content > settings > routes.yaml (under collections)

  /newsletter/:
                permalink: /{slug}/
                template: index

I get a working header banner, it renders, but the sent newsletters won’t show up, it will be empty of content. The “emails” that were sent out do not load as list.

The same happens (working banner but no newsletter content) if I modify both Lyra’s routes.yaml and content > settings > routes.yaml.

Would love any pointers on how to fix this.

Again, the objective is : working banner and list of emails sent out underneath it

Hey! Did you apply a filter to the new newsletter route? The example in the Recipes page you linked to filters the posts depending on whether they a publicly visible or not using filter: visibility:public on the main page and filter: visibility:-public page. You’ll need to add these filters to the routes file and set the visibility to members only on the newsletter posts.

The routes.yaml should be changed in the Ghost admin.

Hope this helps!

Thanks a lot for reverting @DavidDarnes !

I had not when I’ve posted but now I have and I get interesting results.

I’ve also tried both filter: visibility:public and filter: visibility:-public , since it wasn’t clear for me (from reading the documentation) on whether visibility referred to posts in general or to the posts that have actually been “sent by email” (which is what I’m after since I want a newsletter archive).

And I’ve tried

/newsletter/:
    permalink: /{slug}/
    template: index
    filter: visibility:members

Result is the same (and yes, I’ve tried but “signed in” and not):

Then I went on, trying all sorts of combinations, including filters on the main page (as I wasn’t sure from your message whether that would have an impact :slight_smile: ), and when adding filters to “/” I’ve started getting posts on /newsletter. Filters in /newsletter only work if you also have a filter in “/”.

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: visibility:public
  /newsletter/:
    permalink: /{slug}/
    template: index
    filter: visibility:members (or filter: visibility:-public should one want both members and paid-members posts in the list)

But this does not give me what I’m after, I still want all

  1. Free
  2. Members
  3. Paid

posts on “/”, not only “public”. How do I do that? I could simply remove the filter on “/”, but if I do that then the filter under /newsletter stops working…

And I want newsletter to show all emails “sent out”, being them:

  1. Free
  2. Members
  3. Paid

But they need to have actually been sent out.

Then it hit me that the filter is not for whether emails have been sent out, it is simply giving me a filter of the posts… :woman_facepalming:t3: (took me some time :slight_smile: )

I’ve realised this because I’ve posted a “members-only” post and did not “send via email”. The post still showed up on the list in /newsletter.

How do I filter posts by what has been actually sent out via email? I am after creating a newsletter archive

Any further pointers? :slightly_smiling_face: Or any further info you need from me?

Any post can be emailed to your members so you’ll need to mark your posts in a more permanent way, either by setting them to ‘members only’ or by tagging them. Sounds like you want them to be visible even if you’re not a member, so you could use a private tag called #newsletter and then filter by that tag in your collections:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: 'tag:-hash-newsletter'
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: newsletter
    filter: 'tag:hash-newsletter'

If this is what you’re looking for try it out and let me know how you get on :slight_smile:

Thanks a lot @DavidDarnes! :slightly_smiling_face:

That tag hack may do it!

I however would like to have "/" to list all types of posts (those “sent out” and those not “sent out”), while having "/newsletter" list only those posts “sent out”. So, how should I adjust the “/” setting? What should I have instead of “#####” below?

collections:
  /:
    permalink: /{slug}/
    template: index
    #####
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: newsletter
    filter: 'tag:hash-newsletter'

Apologies if this is basics of yaml, but I couldn’t find anything online. :slightly_smiling_face:

Ah I see! In that case you need a channel. Channels are groups of non-exclusive content. You can leave your collections as they are and add a new channel to your routes:

routes:
  /newsletter/:
    controller: channel
    filter: tag:hash-newsletter

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

This will add the posts with a private tag of #newsletter to /newletter/ but they will still appear in the main blog collection :+1:

3 Likes

This worked wonderfully! :blush:

Thanks a ton @DavidDarnes.

Very powerful settings with the tags and channels!

Have a good day/evening ahead!

1 Like

You’re welcome! You too :rainbow: