DEV Community

Carlo Gino Catapang
Carlo Gino Catapang

Posted on • Edited on • Originally published at l.carlogino.com

Remix Search Engine Optimization

TL;DR

Here is the Remix SEO checklist

Introduction: Why bother?

SEO stands for search engine optimization, which is a set of practices designed to improve the appearance and positioning of web pages in organic search results. Because organic search is the most prominent way for people to discover and access online content, a good SEO strategy is essential for improving the quality and quantity of traffic to your website.

Although Remix is a great framework, we still need to manually configure SEO to reach more users. In this blog, I will discuss how to improve SEO in your Remix application.

Check this blog in case you are not familiar with Remix.

High-quality content

This is not Remix specific, but just like in any website, the best way to improve your SEO is to have good content.

Now, let's continue on things we can control, as a developer, in our Remix application.

Using meta tags

Meta tags are specific snippets of text and image content that summarize a web page. Often meta-tag data shows up whenever someone shares a link on social media, in messaging, or in your business chat software.

To render the meta tags that we will declare in our routes, we first need to add the Meta component in the head of your app/root file.

// app/root.jsx
import { Meta} from "remix";

// ...
<html lang="en">
  <head>
    {/* other stuff */}

    {/* All meta exports on all routes will go here */}
    <Meta />
  </head>
  {/* body */}
</html>
// ...
Enter fullscreen mode Exit fullscreen mode

Check this link to see a sample usage of the above code.

You can technically add meta tags directly to the head of the html template. However, it is recommended to add "unique" information such as title and description on every route.

Using Vanila JavaScript

// app/routes/[routeName].jsx
export const meta = () => {
  return {
    [property]: "value"
  }
}
Enter fullscreen mode Exit fullscreen mode

Using TypeScript

// app/routes/[routeName].tsx
import type { MetaFunction } from "remix";

export const meta: MetaFunction = () => {
  return {
    [property]: "value"
  }
}
Enter fullscreen mode Exit fullscreen mode

Remix is smart enough to convert a meta property into the appropriate tag with the correct value as shown in the upcoming examples.

Must have meta tags

Title

A title tag is the second most important factor for on-page SEO, only trailing high-quality content.

export const meta = () => {
  return {
    title: "Page Title. Ideally length 60-70 characters",
  }
}
Enter fullscreen mode Exit fullscreen mode
<head>
  <title>Page Title. Ideally length 60-70 characters</title>
</head>
Enter fullscreen mode Exit fullscreen mode

Description

The meta description often serves as a pitch to people who find your website on Google or social media sites. While it's not required and Google can use text from you website instead of what you specifiy in the meta data, it's better to control the description text where you can.

export const meta = () => {
  return {
    //...
    description: "Page description. No longer than 155 characters."
  }
}
Enter fullscreen mode Exit fullscreen mode
<head>
  <!--...-->
  <meta name="description" content="Page description. No longer than 155 characters.">
</head>
Enter fullscreen mode Exit fullscreen mode

Image

With the visual nature of the web, your Meta Tag Image is the most valuable graphic content you can create to encourage users to click and visit your website.

export const meta = () => {
  return {
    //...
    "og:image": "https://codegino.com/assets/preview.png"
  }
}
Enter fullscreen mode Exit fullscreen mode
<head>
  <!--...-->
  <meta property="og:image" content="https://codegino.com/assets/preview.png">
</head>
Enter fullscreen mode Exit fullscreen mode

Social media meta tags

Although it is not required, with a good social media presence, you can attract more users which will organically increase your search ranking.

OG:info

Open Graph meta tags are snippets of code that control how URLs are displayed when shared on social media.

They're part of Facebook's Open Graph protocol and are also used by other social media sites, including LinkedIn and Twitter (if Twitter Cards are absent).

export const meta = () => {
  return {
    //...
    "og:type": "website",
    "og:url": "https://codegino.com",
    "og:title": "Page Title. Ideally length 60-70 characters",
    "og:description": "Page description. No longer than 155 characters.",
    "og:image": "https://codegino.com/assets/preview.png",
  }
}
Enter fullscreen mode Exit fullscreen mode
<head>
  <!--...-->
  <meta property="og:type" content="website">
  <meta property="og:url" content="https://codegino.com">
  <meta property="og:title" content="Page Title. Ideally length 60-70 characters">
  <meta property="og:description" content="Page description. No longer than 155 characters.">
  <meta property="og:image" content="https://codegino.com/assets/preview.png">
</head>
Enter fullscreen mode Exit fullscreen mode

Adding twitter:info

These are used by Twitter to display information about your website.

You don't define all of these as Twitter will reuse some og meta tags.
In case of an overlap(og:description and twitter:description), Twitter will pick the Twitter-specific information.

export const meta = () => {
  return {
    //...
    "twitter:card": "summary_large_image", // summary, summary_large_image, app, player
    "twitter:creator": "@code_gino",
    "twitter:url": "https://codegino.com",
    "twitter:title": "Page Title. Ideally length 60-70 characters",
    "twitter:description": "Page description. No longer than 155 characters.",
    "twitter:image": "https://codegino.com/assets/preview.png",
  }
}
Enter fullscreen mode Exit fullscreen mode
<head>
  <!--...-->
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:creator" content="@code_gino">
  <meta name="twitter:url" content="https://codegino.com">
  <meta name="twitter:title" content="Page Title. Ideally length 60-70 characters">
  <meta name="twitter:description" content="Page description. No longer than 155 characters.">
  <meta name="twitter:image" content="https://codegino.com/assets/preview.png">
</head>
Enter fullscreen mode Exit fullscreen mode

Putting all the meta tags together

export const meta = () => {
  return {
    title: "Page Title. Ideally length 60-70 characters",
    description: "Page description. No longer than 155 characters.",
    "og:type": "website",
    "og:url": "https://codegino.com",
    "og:title": "Page Title. Ideally length 60-70 characters",
    "og:description": "Page description. No longer than 155 characters.",
    "og:image": "https://codegino.com/assets/preview.png",
    "twitter:card": "summary_large_image",
    "twitter:creator": "@code_gino",
    "twitter:url": "https://codegino.com",
    "twitter:title": "Page Title. Ideally length 60-70 characters",
    "twitter:description": "Page description. No longer than 155 characters.",
    "twitter:image": "https://codegino.com/assets/preview.png",
  }
}
Enter fullscreen mode Exit fullscreen mode

Validators

Here are some validators that you can use to test your meta tags.

Sitemap.xml

A sitemap is a file where you provide information about the pages, videos, and other files on your site and their relationships. Search engines like Google read this file to crawl your site more efficiently. A sitemap tells Google which pages and files you think are important in your site and provides valuable information about these files. For example, when the page was last updated and any alternate language versions. Learn more

Create a sitemap.xml inside the public directory

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://codegino.vercel.app</loc>
    </url>
    <url>
        <loc>https://codegino.vercel.app/words</loc>
    <lastmod>2022-03-20T20:58:44.110Z</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.7</priority>
    </url>
</urlset>
Enter fullscreen mode Exit fullscreen mode

If you have a lot of dynamic pages, you can create a sitemap generator.

Robots.txt

A robots.txt file tells search engine crawlers which URLs the crawler can access on your site. This is used mainly to avoid overloading your site with requests; it is not a mechanism for keeping a web page out of Google. Learn more

Create a robots.txt inside the public directory

User-agent: *
Allow: /
Enter fullscreen mode Exit fullscreen mode

Additional things to consider

Top comments (0)