Abstract newspaper with a mountain range subtly hinted

Create a Google News sitemap

Reach new audiences by having your content show up in Google News. Readers get the benefit of discovering your content in a single hub and the ability to share and bookmark articles easily. Learn everything you need to know about adding your Ghost site to Google News in this tutorial.


Add your content to Google News by adding a Google News sitemap to your Ghost site. The sitemap lets Google News know all the important details about your published content.

This tutorial walks you through how to create a Google News sitemap by implementing a new route on your Ghost site and by creating a custom template that is fully optimized for the Google News aggregator.

Add a new route for your sitemap

To make your sitemap accessible on the web, add a new route using Ghost's dynamic routing layer.

Download the most up-to-date version of your routes.yaml file from Ghost Admin. Go to Settings LabsDownload current routes.yaml. Open the file in your code editor of choice.

Ghost Admin, upload and download custom routing

Add the following route:

routes:
  /sitemap/:
    template: sitemap
    content_type: text/xml

This entry tells Ghost to create a route at yoursite.com/sitemap/, and on that route, to serve the sitemap template file and send an XML response (which is what Google News expects).

Your routes.yaml file should now look like the file below, plus any other changes you may have made to it.

routes:
  /sitemap/:
    template: sitemap
    content_type: text/xml

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

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

Save the file and upload it to Ghost Admin (Settings LabsUpload routes YAML).

Create a template for the Google News sitemap

The next step is to create a Handlebars template in your theme. This requires a little bit of coding, but the example in this tutorial provides a fully functional starting point.

Create a new file in the root of your theme called sitemap.hbs.

Add your posts

The code below tells Ghost to fetch your latest 1,000 posts created in the last two days and format the information for Google News. The template follows the specifications for a Google News sitemap like including the title and publication date as well as indicating if the content is for members only.

<?xml version="1.0" encoding="UTF-8"?>
  <urlset
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
  >
    {{#get "posts" filter="published_at:>now-2d" limit="1000" include="tags"}}
      {{#foreach posts}}
        <url>
          <loc>{{url absolute="true"}}</loc>
          <news:news>
            <news:publication>
              <news:name>{{@site.title}}</news:name>
              <news:language>{{@site.locale}}</news:language>
            </news:publication>
            {{#has visibility="members"}}
            <news:access>Registration</news:access>
            {{/has}}
            {{#has visibility="paid"}}
            <news:access>Subscription</news:access>
            {{/has}}
            <news:publication_date>{{date published_at format="YYYY-MM-DDTHH:mm:ssZ"}}</news:publication_date>
            <news:title>{{title}}</news:title>
            <news:keywords>{{tags limit="5" autolink="false"}}</news:keywords>
          </news:news>
        </url>
      {{/foreach}}
    {{/get}}
  </urlset>

Copy and paste this code to the sitemap.hbs file or customize it to suit your needs. With customization, be aware that Google is stringent about attributes and formatting, so be sure to include all required fields.

Update your theme

Save the new template, zip up your theme, and upload it to your Ghost site. Check to see if your Google News sitemap is active by visiting yoursite.com/sitemap/. (We added a sitemap to this Tutorials site as an example: https://ghost.org/tutorials/sitemap/. Note that if no tutorials have been published in the past two days, the sitemap will be empty.)

Google News sitemap example

Submit your Google News sitemap

Google Search Console is essential for monitoring your search performance in Google. See our guide on integrating it with Ghost. It's also the best way to let Google know about your new Google News sitemap.

In Google Search Console, go to Sitemaps and add your new URL to the Add a new sitemap box. Click Submit. The sitemap should be fetched immediately, but occasionally it can take some time for Google to crawl the URLs listed in it. A successful status indicates that Google has indexed all of your links submitted to Google News. That means your content is available to show up on Google News 📰

Customize how your publication shows up in Google News by configuring it through Google's Publisher Center. Via the Publisher Center, you get advanced control over content and branding, monetization opportunities, and additional placement eligibility.

Summary

In this tutorial, you used Ghost's routing system and theme layer to create a custom Google News sitemap 🙌

Creating the sitemap helps your content show up in Google News, but Google also provides several other options for customization, monetization, and improved placement. See Google's guide to learn more.

Having trouble with this tutorial or seeing great success with your new Google News sitemap? Come share your experience in the official Ghost Forum, where developers, publishers, and content creators come together to discuss all things Ghost.

On this page Introduction

How was the tutorial?

Be the first to know.

Join the Ghost developer community — sign up to get early access to the latest features, developer tools, and tutorials.

No spam. Once a month. Unsubscribe any time.