How do i use the SEO plugin?

I also finded a way to populate the fields on the controller instead params, could’be it’s usefull aswell.

Edit the controller and add the populate fields on the return, in my example the content ins named “homepage”, so the file should be “src/api/homepage/controllers/homepage.js”, inside the code should be something like:

'use strict';

/**
 *  homepage controller
 */

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::homepage.homepage', ({ strapi }) => ({
    async find(ctx) {
        const populateList = [
            'firstSection.*',
            'secondSection.*',
            'thirdSection.*',
            'contact.*',
            'seo.*',
            'seo.metaImage'
        ]
        // Push any additional query params to the array
        populateList.push(ctx.query.populate)
        ctx.query.populate = populateList.join(',')

        const content = await super.find(ctx)
        return content
    }
}));
1 Like