SEO
Source: NextJS tutorial on SEO
(I'm focusing on the technical stuff. See this in action in my post, on how I built my website)
SEO Pillars
- Technical -- What the developer does
- Creation -- The content on the website
- Popularity -- Backlinks to your site from reputable sites
First off, fundamental knowledge
As search engine web crawlers and users visit your web pages, they may encounter one of these HTTP status code messages. Some can affect your SEO!
HTTP status code | Meaning | Notes |
---|---|---|
200 | Ok | |
301/308 | Permanent redirect | |
302 | Temporary redirect | |
404 | Not found | Hurts search rankings if you have too many |
410 | No longer available |
|
500 | Server error | |
503 | Server down for a long period of time | Maintains search rankings |
Explicit things you can do
There's a collection of obvious things developers do to improve SEO. Here they are.
HTML files and tags | Meaning | Notes |
---|---|---|
robots.txt | Indicates which pages/files web crawlers can access and crawl | Useful robots.txt rules |
sitemap.xml | Tells Google the URLs in your site so it can crawl it more efficiently and crawl new pages when the sitemap changes. | Best to make it dynamic and use the [object Object]. |
HTML Head meta tags for search engines | Directives that search engines always respect.E.g.don’t index this page, don’t follow links from this page, don’t translate it’s content, don’t show a search bar for the site on Google. | Helpful NextJS post |
Head canonical link tags | Tells Google the page that’s the origin of truth. | Critical if you have duplicate content on pages with different URLs, otherwise Google penalizes you. |
Title and description tags |
| |
Open Graph Tags (ogp.me) | Used by companies like Twitter to show rich UI cards when people link to your site | |
Structured JSON-LD Data (schema.org) | Even more data to describe your content for search engines. |
Implicit things you can do
These are strategies not so obvious that developers can do to improve SEO.
Topic | Advice |
---|---|
Rendering | Most important thing for SEO is that page metadata and content is available without running JavaScript.
|
On Page SEO |
|
URLs |
|
Google AMP | Code from Google that use to improve SEO but doesn't anymore. |
Measuring Performance
Web Vitals are Google's terms referencing how they measure website performance.
The Core web vitals is a subset of web vitals that have 3 metrics that measure loading, interactivity, and visual stability performance:
- LCP (largest contentful pain)
- Time it takes for the largest element to load on the webpage
- FID (first input delay)
- Time it takes for user's input to do something on the webpage
- CLS (cumulative layout shift)
- Elements shifting after already being rendered
Google uses a website's core web vital scores to help rank them.
- Scores are: Good, Needs improvement, Poor.
Tips to improve Web Vital Scores
- Optimizes images and fonts.
- NextJS Image
<Image src={...} />
- Helps LCP and CLS score
- NextJS Image
- Use dynamic imports when possible
await import(...)
- Gets rid of warning to remove unused Javascript.
- Helps FID score
- Defer loading third-party scripts until after the webpage content loads.
import Script from "next/script"