How to remove no-idex pages from sitemap.xml?

Hi! Sitemap.xml should only have URL that are not marked with no-index. At the moment, if I add “” to a certain page or post, this URL still appears in sitemap.

This is something that all other publishing platforms (including WordPress, which Ghost calls itself better) do automatically.

Why is this happening, and how we can get noindex-URL’s removed from sitemaps?

So Ghost doesn’t add a url to the sitemap if there’s a canonical URL available. (You can set the canonical URL in the right side menu - scroll down for metadata.)

Last time I tried it (it’s been maybe a month), setting a post’s canonical URL to itself caused the post to disappear from the sitemap.

2 Likes

Thanks Cathy, this worked.

Ghost still has a lot of work to do on their own ghostseo site to get this information there too, but I’m glad you took the time to help me.

Glad to have helped, Mari. It’s possible the behavior that’s fixing your problem is actually unintended. Hopefully the Ghost team will eventually address this need in a way that’s not kludgy. Meanwhile, you could start a post in the Ideas forum explaining this need (if there isn’t one already), or vote for an existing idea.

1 Like

I noticed that this works fine for static pages. However, I have several pages that serve as collections. They are also mentioned in the routes.yaml.

Even though I tried this hack with canonical URL, these pages still appear in sitemap.xml.

Any idea how I can remove these pages from sitemap?

Did some testing and found out:

  • the page itself is removed from the sitemap (even if it is a collection page), when you use this hack with canonical URL
  • however, one entry for this page remains on the sitemap due to its entry in the routes.yaml

This means that Ghost sitemap creates per default two sitemap entries: one based on the route in the routes.yaml and one for the page itself. The entry for the page itself can easily be excluded via the canonical URL in the meta config.

Any idea how to get rid of the other entry that comes from the routes.yaml?