sanity-plugin-seo-tool
v1.2.0
Published
An SEO analysis tool for Sanity CMS
Downloads
39
Readme
Installation
- Run the following npm in your terminal:
npm install sanity-seo-checker-plugin
Configuration
- Go to your sanity.config.js file and add the following code:
import { defineConfig } from 'sanity'
import { seoTool } from 'sanity-plugin-seo-tool'
export default defineConfig({
// ...
plugins: [seoTool()],
// ...
})
- Go to your sanity.config.js file and add the following code:
schema: {
types: schemaTypes.map(schemaType => {
if (schemaType.name === 'post') {
return {
...schemaType,
fields: [
...schemaType.fields,
{
name: 'seoAnalysis',
title: 'SEO Analysis',
type: 'object',
fields: [
{
name: 'keyword',
type: 'string',
title: 'Keyword'
},
{
name: 'keywordCount',
type: 'number',
title: 'Keyword Count'
},
{
name: 'keywordInTitle',
type: 'boolean',
title: 'Keyword in Title'
},
{
name: 'keywordInH2',
type: 'boolean',
title: 'Keyword in H2'
},
{
name: 'wordCount',
type: 'number',
title: 'Word Count'
},
{
name: 'keywordPercentage',
type: 'number',
title: 'Keyword Percentage'
}
],
components: {
input: SEOTool
}
}
]
};
}
return schemaType;
})
},
- Go to src/config.example.js and rename it to config.js.
- Add your API key to the config.js file (get your API key at https://slashseo.com)
- Save all files and run the following npm:
npm run dev
Usage
- Go to your Sanity Studio and create a new post or edit an existing one.
- Go to your document and click on the SEO Analysis field (this will be displayed below the content Body field)
- The SEO analysis will be displayed in the SEO Analysis field.
- Click "Analyze SEO" to run the analysis or after making changes to your content to get the latest insights and score.