Republish content
Sometimes it may be necessary to republish content to the Publishing API. This will refresh the content on the website.
For example if we make an update to govspeak and a publishing application pre-renders that content prior to its submission to Publishing API, that would require us to re-render and save new HTML for content.
This process varies per app and requires
- Connection to the [VPN][vpn] and
- Production access
You may wish to test first on integration, prior to carrying out the republish in production.
Whitehall
If the documents are in Whitehall, there are Rake tasks you can run as outlined below. Try to pick the one most focused to the scope of what you need to republish to avoid unnecessary load. You can monitor the effect on the publishing queue via these Grafana dashboards:
To republish a single document by slug
- Run publishing_api:republish:document_by_slug[slug] on Integration
- Run publishing_api:republish:document_by_slug[slug] on Staging
- ⚠️ Run publishing_api:republish:document_by_slug[slug] on Production ⚠️
Replace
slug
with the document’s slug, but not the full base path. For example the slug forhttps://www.gov.uk/government/important-news
would beimportant-news
.
To republish all documents of a specific type
To republish all instances of the following document types, run the following rake task.
- CaseStudy
- Consultation
- Contact
- CorporateInformationPage
- DetailedGuide
- DocumentCollection
- FatalityNotice
- Government
- NewsArticle
- OperationalField
- Organisation
- Person
- PolicyGroup
- Publication
- Role
- RoleAppointment
- Speech
- StatisticalDataSet
- StatisticsAnnouncement
- TakePartPage
- TopicalEvent
- TopicalEventAboutPage
- WorldLocation
- WorldLocationNews
- WorldwideOffice
- WorldwideOrganisation
- Run publishing_api:bulk_republish:document_type[DocumentClass] on Integration
- Run publishing_api:bulk_republish:document_type[DocumentClass] on Staging
- ⚠️ Run publishing_api:bulk_republish:document_type[DocumentClass] on Production ⚠️
Replace
DocumentClass
with the camelized (i.e. as it is written above) class name.
To republish multiple documents
For a small number of documents, use the following rake task:
- Run publishing_api:bulk_republish:documents_by_content_ids[content_id_1 content_id_2] on Integration
- Run publishing_api:bulk_republish:documents_by_content_ids[content_id_1 content_id_2] on Staging
- ⚠️ Run publishing_api:bulk_republish:documents_by_content_ids[content_id_1 content_id_2] on Production ⚠️
Replace
content_id_1
andcontent_id_2
with the content ID (i.e. UUID) for the documents to republish. You can add more than 2 content IDs.
For a significant number of documents, a CSV file should be added to the repository:
- Create a CSV file that contains a single column headed
content_id
. Put the content ID for each document on a separate line below this. The file should be saved inlib/tasks/{FILENAME}.csv
and a PR raised. - Merge and deploy the PR to the relevant environment.
- Run the
documents_by_content_ids_from_csv
rake task:
Replace
csv_file_name
with the filename of the CSV, including the.csv
extension. 1. After the job has completed, remove the CSV from the repository.
To republish all documents
Caution: this is a lot of content and will take hours to complete. If it is possible to scope the republish do so and use a different task, but if you have made a change such as something in govspeak that will affect the majority of content, this is available. Before running this job confirm with Technical 2nd Line that they are happy for you to proceed as it could cause backed up publishing queues and alerts.
- Run publishing_api:bulk_republish:all on Integration
- Run publishing_api:bulk_republish:all on Staging
- ⚠️ Run publishing_api:bulk_republish:all on Production ⚠️
Content Publisher
If the document is in content publisher, there is a resync Rake task you can run.
You can resync a single document by passing it a content ID and locale:
- Run resync:document[a-content-id:locale] on Integration
- Run resync:document[a-content-id:locale] on Staging
- ⚠️ Run resync:document[a-content-id:locale] on Production ⚠️
or you can resync all documents: