Headless CMS includes only the back-end functionalities (creation and storage of your content) and makes use of REST API or GraphQL API to display content in the front-end. This gives the opportunity to make use of modern web technologies for the front-end, while the back-end makes use of a dedicated content management system.
If your website makes use of WordPress as the headless CMS, thankfully, Rank Math offers a REST API endpoint to support headless CMS. So you can make use of this feature and let Rank Math take care of the technical SEO aspects of your website while your website can use any modern web technologies without worrying about SEO.
Note: This tutorial is intended for developers and users who are familiar with handling headless websites.
1 Headless CMS Support in Rank Math
In this knowledgebase article, we’ll walk you through how to enable headless CMS support in Rank Math, and you can get started by following the steps discussed below.
1.1 Navigate to Rank Math General Settings
Start by heading over to Rank Math > General Settings > Others inside your WordPress admin area. If the Others tab is unavailable for you, then ensure that you’re using Rank Math in advanced mode.
1.2 Enable Headless CMS Support
Then, enable the Headless CMS Support option as shown below.
1.3 Save Changes
Finally, click the Save Changes button at the bottom of the screen to reflect the changes.
1.4 Rank Math REST API Syntax
Now you’ll be able to send a GET request to our REST API endpoint for a specific URL, and the API would return the meta tags added by Rank Math for that URL.
To send a request, use our
getHead REST endpoint, followed by the URL of the webpage. You can add your posts/categories/user pages or any internal URL and even invalid URLs like 404s/other errors. Here is an example of how to create a request.
Make sure to replace
your-domain.com with your website’s domain and then
https://your-domain.com/hello-world with your URL. The data will now be returned in a JSON format that contains,
trueon successful retrieval
head– contains the HTML tags added by Rank Math
Now, you can make use of the head data in your favorite front-end web app and still take advantage of Rank Math’s on-page optimization.
2 Allow Firewall to Access Rank Math’s REST Endpoint
If you’re unable to access Rank Math’s REST endpoint, it is possible that your website uses any security plugin that blocks your access to Rank Math’s endpoint. To ensure that you’re able to retrieve the meta tags with this method, you’ll need to whitelist the following REST API endpoint in your firewall.
3 Fixing Errors with REST API Endpoint
In case if you’re receiving an error message while attempting to retrieve meta tags, the following steps will help you resolve them.
3.1 Invalid Parameter(s) URL
You’ll likely see this error if the added URL is incomplete or empty. The URL parameter looks for a full URL (for instance, the current page’s URL should be used as,
https://rankmath.com/kb/headless-support/), and instead, if you’re using only slugs (like
/headless-support/) the API endpoint will return this error.
3.2 Missing Parameter(s) URL
This error message is seen when your request does not include the URL parameter as described.
Here is an example of how you can request data from the endpoint and make sure to include the URL parameter that follows the
And, that’s it! We hope the tutorial helped you retrieve your page’s HTML tags added by Rank Math. If you still have absolutely any questions, please feel free to reach our support team directly from here, and we’re always here to help.