Home / Blog posts

SEO tips and tricks for Strapi v4

strapi seo
But why?

Optimizing your website for search engines is crucial for visibility. Strapi, as a flexible headless CMS, provides powerful tools for SEO. Here's a streamlined guide to help you set up and enhance SEO in Strapi.

Key Aspects to Consider

  1. Construction of URLs
  2. Metadata and Media
  3. Structured Data
  4. Content Clustering
  5. Sitemap
1. Construction of URLs

Importance:

  • URLs are crucial for search engine indexing and user navigation.
  • Use slugs over IDs for readability and SEO benefits.

Setup in Strapi:

  1. Create a Product Content-Type:
  2. Fields:name (Text)slug (UID attached to name)
  3. Steps:
  4. Go to Content-Type Builder.Add the name field as Text.Add the slug field and attach it to the name.

Example:

  • Bad: example.com/products/1234
  • Good: example.com/products/my-awesome-product
2. Metadata

Importance:

  • Helps search engines understand page content.
  • Key for on-page SEO.

Main Tags:

  • Title: No more than 60 characters. Include 1-2 keywords.
  • Description: No more than 155 characters. Include 2-3 keywords.
  • Keywords: Relevant to the content.
  • Robots: Controls how search engines interact with the page.

Setup in Strapi:

  1. Fields:
  2. metaTitle (Text)metaDescription (Text)shareImage (Component with alternative text)preventIndexing (Boolean)
  3. Component Code:
const Seo = () => {
  const { title, description, url, shareImage, keywords, preventIndexing } = useContext(SeoContext);

  return (
    <Head>
      <title>{title}</title>
      <meta name="description" content={description} key="description" />
      <meta name="keywords" content={keywords} />
      <meta name="twitter:card" content="summary_large_image" key="twitter:card" />
      <meta property="og:url" content={url} key="og:url" />
      <meta property="og:title" content={title} key="og:title" />
      <meta property="og:description" content={description} key="og:description" />
      <meta property="og:image" content={shareImage} key="og:image" />
      <link rel="canonical" href={url} />

      {preventIndexing && (
        <>
          <meta name="robots" content="noindex"></meta>
          <meta name="googlebot" content="noindex"></meta>
        </>
      )}
    </Head>
  );
};
3. Structured Data

mportance:

  • Provides explicit clues about the meaning of a page.
  • Improves search engine understanding.

Setup in Strapi:

  1. Use JSON-LD:
const Microdata = ({ type, data }) => {
  const structuredData = JSON.stringify(data);

  return (
    <Head>
      <script type="application/ld+json">{structuredData}</script>
    </Head>
  );
};
4. Content Clustering

Importance:

  • Organizes content thematically.
  • Enhances relevance and authority for search engines.

Implementation:

  • Group related content into clusters.
  • Link cluster content to a central pillar page.
5. Sitemap

Importance:

  • Helps search engines discover and crawl site pages.
  • Reflects site structure and hierarchy.

Setup in Strapi:

  1. Generate Automatically:Use a community-contributed plugin (e.g., by Boaz Poolman).

By following these steps and leveraging Strapi's flexibility, you can significantly enhance your website's SEO performance.

For further details, check out Strapi SEO Best Practices.

Got a project?
Jiri Mouka photo

Jiri Mouka | Founder

+41 076 629 91 78

sales@notum-tech.ch