Get 404 error on tagged posts when using filter: tag:-[profiles] on index.hbs

Am missing something obvious here? I have a ghost blog site recently set up, I have created test posts tagged with “profile”.

I’d prefer not to show profile posts on the index page at https://bundupress.com/ as they are a sort of company profile directory, which will amount to 1000’s, so these should only be found at https://bundupress.com/directory/

I edited my routes.yaml as follows:

I created a route for posts tagged with “profile”.

routes:
/directory/:
controller: channel
filter: tag:profiles
theme: profiles

I filtered posts tagged with “profile” from route.

collections:
/:
permalink: /{slug}/
template: index
filter: tag:-[profiles]

The filter removes “profile” tagged posts as expected at bundupress.com/ and I can navigate to url and see the looped profile posts ie. /directory/

The issue: When you select a profile post to show the profile post ie. /directory/profile-one/, you get 404 error!

Sorry new to ghost and probably rookie error, not sure if there is a rule or better way to do this that I have missed.

Steps I have taken to test various scenarios.

  1. I tried different themes.
  2. I changed “profiles” in routes.yaml to filter tag “startups”, same 404 issue but now on startups.
  3. I created a separate home.hbs page as site root, same issue.
  4. I created separate templates ie. theme: profiles.
  5. I used {{#get “posts” filter="tags:-[profile] in index.hbs instead of routes.yaml, which works but still get 404 error.

Sorry babbling… any suggestions would be awesome.

How about creating a collection for /directory as well?

/directory/:
  permalink: /directory/{slug}/
  template: profile
  filter: tag:profiles
  data: tag.profiles

Your current profile URL format is /p/POST_ID, so that might be the reason why it shows 404.

2 Likes

Hi @minimaluminium, thank you very much, that worked, awesome!

1 Like