Page primary_tag is null when first tag is a private tag

When the first tag of a page is a private tag (indicated by the hashtag, e.g. #private), then the primary_tag value returns as null.

This is true even if the page has other tags.

Not sure if this is expected functionality, although it would seem odd given that private tag objects are still returned as part of the tags array.

Any tag that is added first becomes the primary_tag. Private tags are that, private, so returning it would kinda defeat the object. What are you trying to achieve with returning the primary_tag?

Thanks, David.

I guess I understand private as being “internal”…hidden from the end-user, but not from the developer/admin, and not invisible from a content API standpoint. As I mentioned, private tags are still included in the tags array…just excluded from whatever is setting primary_tag. I don’t see a logical reason for including them in one but not the other.

Not trying to do anything crazy…just pull a certain selection of posts and/or pages that are flagged with a tag, but I do not want that tag to be rendered publicly. I can accomplish this other ways, but the behavior above still seems odd to me.

This is absolutely the expected behaviour for all the reasons Dave outlined.

Internal tags are as you say internal to the developer, and only provided in certain contexts, if we used internal tags as primary tags they would potentially be exposed outside of those contexts - for example in URLs. This is a very logical reason.

The fix is to reorder the tags.

1 Like

Not to be contrary, but @DavidDarnes didn’t really provide a reason…just stated that “private tags are private”.

If we’re saying that “primary_tag” is inherently public and incompatible with the concept of being “internal” only…then OK. I would suggest updating documentation on Internal Tags and primary_tag then. While I get that it could be intentional, it is not self-evident.

Just had another read of both the concept of Primary tags and Internal tags, they’re both very clear in their behaviours :+1:

It would be great if you were to explain what you’re trying to achieve so we can help :slightly_smiling_face:

Hey Dave,

The thing I’m trying to achieve (basically looking for a list of posts that contain a specific private tag) can be done other ways that are just a little more complicated. I appreciate the help offer, but I’m good there. I was really just trying to understand functionality.

Can you point me to where you’re reading a clear description of the relationship between primary and internal tags, or something that indicates primary_tag would be null when the first of multiple tags on a post/page is private? I’m not seeing that in either the Core Concepts section, or the API Reference (I did try to make an effort to look before asking, but maybe I just missed it).

The closest thing I can find on this subject the discussion of visibility in the data helpers section, but that’s not quite what I was looking for.

Ghost has a concept of primary_tag , used simply to refer to the very first tag which a post has…

…internal tags within Ghost - which is to say that they aren’t rendered publicly…

There isn’t a relationship that needs to be explain, they have conventions which are both explained and are being followed

I feel like we’re talking past each other a bit, so perhaps we agree to disagree. My suggested edits to clarify things are below, but if you don’t agree that there is a need for more clarity…so be it. Thanks for the chat. :+1:

Primary Tag

Ghost has a concept of primary_tag , used simply to refer to the very first tag which a post has…

"…except when the very first tag is internal"
or, alternatively
“…only when the first tag is public…”
or, if you wanted to tweak functionality a bit to accommodate
…refer to the very first public tag…"

Internal Tag

…internal tags within Ghost - which is to say that they aren’t rendered publicly…

*“…or included in inherently public properties such as primary_tag…”