Table of contents
This page was set to be reviewed before 2017-11-08 by the page owner: @davidslv and @matmoore. This might mean the content is out of date. Read how to review a page

Add a new document type

The document type describes what a page on GOV.UK looks like.

Add the document type in the govuk-content-schema repo

You need to add the document type into the allowed document types in content-schemas.

Once you have added the document type you should:

  • commit the change
  • run the default rake task to generate the schemas again
  • commit this update separately

Examples of implementation:

Create a new rake task in the Publishing API

The rake task will publish the route using the new document type.

Before you begin you must identify which publishing and rendering applications will use the document type. You need to include these as parameters (payload) when you generate the route.

Examples of implementation:

You should publish your new content item with your document type to the Publishing API, especially if you want it to be part of search as it makes it easy to integrate search this way.

Please note

Having a document type with placeholder prefix will not publish routes. More information can be found here under placeholder items.

Add a new content schema

If you need help with adding a new schema in govuk-content-schemas please read the following: https://github.com/alphagov/govuk-content-schemas/blob/master/docs/adding-a-new-schema.md

Any document type that the publishing api knows about can be added to our internal search. By default, all document types in internal search also get included in the GOV.UK sitemap, which tells external search engines about our content.

The app responsible for search is Rummager. Rummager listens to RabbitMQ messages about published documents to know when to index documents. For the new document type to be indexed, you need to add it to a whitelist.

Rummager has it’s own concept of document type, which represents the schema used to store documents in Elasticsearch (the search engine).

Normally, you’ll map your document type an existing rummager document type. If in doubt, use “edition” - this is used for most documents.

Then, modify mapped_document_types.yml with the mapping from the publishing api document type.

If you want search to be able to use metadata that isn’t defined in an any rummager document type, then you’ll need to add new fields to rummager.

Rummager knows how to handle most of the core fields from the publishing platform, like title, description, and public_updated_at. It looks at the body or parts fields to work out what text to make searchable. If your schema uses different fields to render the text of the page, update the IndexableContentKeys module as well.

The part of rummager that translates between publishing api fields and search fields is elasticsearch_presenter.rb. Modify this if there is anything special you want search to do with your documents (for example: appending additional information to the title).

2. Add the document type to migrated_formats.yaml

Add the document_type name to the migrated list in rummager.

3. Republish all the documents

Republish all the documents and they should appear in search. You can test this through the API using a query such as:

This page is owned by @davidslv and @matmoore and needs to be reviewed