logo

Best Practices

These are some best practices that I've learned by building this website, they should be useful for other content-heavy websites, including blogs; especially statically generated ones.

Google Analytics and Google Search Console

Probably the first thing you need to do is to setup Google Analytics and Search Console, you simply cannot improve it if you cannot measure it. And make sure you generate a sitemap and add it to Search Console.

Alexa was useful for checking the estimated overall websites rankings but it was shut down in 2022. Alternatives: Similarweb (only includes websites with >50k monthly visits), Semrush, Ahrefs, SpyFu.

Google Analytics 4 (GA4) is now the default and recommended version of Google Analytics, replacing Universal Analytics (UA) which dates back to 2013. Universal Analytics will stop working in 2023.

GA4 uses gtag.js Global site tag (gtag.js, default) or Google Tag Manager (more advanced features).

GA4 doesn’t rely on cookies and uses an event-based data model for measurement. It also does not store IP addresses, which can help brands stay on the right side of privacy regulations.

  • UA: sessions focused (num of sessions, bounce rate, session duration, pages per session, etc.) The concept of a session can be difficult to apply to mobile and single-page apps.
  • GA4: events and users focused (events, event parameters, and user properties).
    • events: e.g. page_view
    • parameters: describe the events
    • user properties: describe the user

Search Console Errors

Alternate Page with Proper Canonical Tag: The “Alternate Page with Proper Canonical Tag” status message in Google Search Console means that there are two versions of a page on your website having the same canonical URL. Google will simply exclude the duplicate version and index the main version of the page.

Use HTTPS and HTTP/2

HTTPS makes it secure, HTTP/2 makes it fast. CloudFlare can provide it, for free. Add Always Use HTTPS rule to URL http://*example.com/*

Prefer Static Websites

If you want to create a wordpress blog website, think again. Static websites are much easier to manage, you do not need to maintain your server and database. Deploying it to a cloud storage like S3 is super cheap, and fast to visit. This website is using GatsbyJS.

No Empty Or Thin Pages

Search engines prefer longer articles; Google AdSense would reject you if you do not have enough content, or empty pages.

No Scraped Content

Google AdSense would also reject you if your content is copy-and-paste from other websites. Of course they are not publishing the standard, but I do not think quoting just one line would disqualify you, the baseline is that you need to provide some extra value to your audience. So if you want to borrow some content, at least try to understand the gist and rephrase in your own words.

Use Google's Lighthouse To Audit Your Website

Now Lighthouse is integrated into Chrome's Developer Tools, you can find the last tab called "Audits", you will get scores and improvement suggestions.

Also the pagespeed tool: https://developers.google.com/speed/

No Trailing Slash

So that the count of the pageviews is accurate.

No Deadlinks

Deadlinks may hurt your ranking. Use a tool to check deadlinks, e.g. broken-link-checker

Privacy Policy

Make sure you have a privacy policy page, and make it easily accessible. Some ads or affiliate networks do not require the privacy policy(you still should have it) but ask you to disclaim that you are affiliated and earn money from displaying their ads. Read carefully.

CloudFlare Page Rules

Add CloudFlare rule:

Always use www: this redirects example.com to www.example.com.

  • example.com/*
  • Forwarding URL (301 Permanent Redirect)
  • https://www.example.com/$1

Always Use HTTPS: this will redirect all http traffic to https.

  • http://*example.com/*
  • Always Use HTTPS

Redirect /path/to/page/index.html to /path/to/page/:s

  • https://www.example.com/*/index.html
  • Forwarding URL (301 Permanent Redirect)
  • https://www.example.com/$1/

Branding

  • Choose your theme color, e.g. we are primarily using green, with some blue as highlights.
  • design some logo/favicon
  • register your name in social medias like Twitter or Instagram, even if you do not plan to use them right away.

Contact

It is important to get feedbacks

  • use social media
  • add the email on your pages, if you have privacy concerns, use the forward function, e.g. [email protected] is actually forwarding emails to a private gmail account.

Format Code

Use prettier:

  • use prettier extension in VS Code
  • from command line. Add this to package.json and then run npm run format:
"scripts": {
  "format": "prettier --trailing-comma es5 --single-quote --write \"src/**/*.js\"",
},

Anchor Text

e.g.

<a href="http://en.wikipedia.org/wiki/Main_Page">Wikipedia</a>

"Wikipedia" is the anchor text in this example. Anchor text is weighted (ranked) highly in search engine algorithms, because the linked text is usually relevant to the landing page. Do not use generic words like "Click here".

ads.txt

https://support.google.com/adsense/answer/7532444?hl=en

Canonical Url

Set "canonical" url in <head>:

<link rel="canonical" href="https://example.com/path/to/page" />

Core Web Vitals (Google Search)

3 metrics:

  • LCP: Largest Contentful Paint.
  • FID: First Input Delay.
  • CLS: Cumulative layout shift.

CLS: Cumulative layout shift

CLS = how much content on the page moves about during the load.

How to improve:

  • reserve ad space: set a min-height for the the ad container.
  • preload web fonts. (unlike web-safe fonts, web fonts needs to be downloaded first). Next provides built-in Font Optimization: https://nextjs.org/docs/basic-features/font-optimization.
  • specify image sizes (width and height).

Not being used for AI

Get scraped and indexed by crawlers like the Googlebot while avoiding having their data used to train AI models as they develop over time. https://developers.google.com/search/docs/crawling-indexing/overview-google-crawlers

Internal links

Help search engines to understand the relevance of pages and the relationship between pages;

Orphaned content: pages that have no internal links pointing to them.

Adding internal links to your newly published pages provides search engines with more ways to reach those content.

Using subdomain may hurt SEO

They are treated as separate sites and may compete with each other if they are in the same domain

Be Patient

Especially if you rely on organic search traffic. Search engines may "freeze" your website upon its creation for at least 6 months before they start to index the content, even after that the "age" of the website may(or may not, we do not know) be a variable for ranking.