Zum Hauptinhalt springen
•
Podcasts & Audio BriefingsCIO: Why trust is a key ingredient for AI that transforms(08.10.2026 um 18:04 Uhr)
•
YouTube Security VideosGoogle DeepMind: From deepfakes to DNA: the science of watermarking AI(01.10.2026 um 18:37 Uhr)
••
YouTube Security VideosIBM Technology: IDE vs CLI: What Every DevOps Engineer Should Know(05.10.2026 um 13:00 Uhr)
•
YouTube Security VideosIBM Technology: Even Tech Experts Hate CAPTCHAs 😅(08.10.2026 um 18:15 Uhr)
•
YouTube Security VideosIBM Technology: Human Bias is Harder to Fix than AI Bias🧠(09.10.2026 um 18:00 Uhr)
••
YouTube Security VideosIBM Technology: 5 Concepts to Know for Coding with AI Agents(12.10.2026 um 13:00 Uhr)
•••
Podcasts & Audio BriefingsCIO: Why trust is a key ingredient for AI that transforms(08.10.2026 um 18:04 Uhr)
•
YouTube Security VideosGoogle DeepMind: From deepfakes to DNA: the science of watermarking AI(01.10.2026 um 18:37 Uhr)
••
YouTube Security VideosIBM Technology: IDE vs CLI: What Every DevOps Engineer Should Know(05.10.2026 um 13:00 Uhr)
•
YouTube Security VideosIBM Technology: Even Tech Experts Hate CAPTCHAs 😅(08.10.2026 um 18:15 Uhr)
•
YouTube Security VideosIBM Technology: Human Bias is Harder to Fix than AI Bias🧠(09.10.2026 um 18:00 Uhr)
••
YouTube Security VideosIBM Technology: 5 Concepts to Know for Coding with AI Agents(12.10.2026 um 13:00 Uhr)
••
Intelligence View
⚡ tsecurity.de Intelligence

Randomizing pages titles (and having good SEO)

I recently implemented a new feature on my portfolio website where the website randomizes its title every time its refreshed. An example of that: This article…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

I recently implemented a new feature on my portfolio website where the website randomizes its title every time its refreshed.

An example of that:



Gif of the changing page titles



This article is about how I implemented this (with code examples in NextJS) and how I fixed my SEO.





Why would you need to fix your SEO?



The issue with the changing page titles is simple: Every time the google crawler goes onto your website he sees a different title that gets indexed, changing it in the search results.

That can mess with your SEO, as something like "[Your Name]'s personal website" is much better for finding the website than "Ran on my machine".





Implementing the titles



This tutorial on how to implement it will be in NextJS, but you can follow along in every language, as it shouldn't change depending on the language.





Setting the title for the Google crawler



First you want to go on your _document.jsx, or inside of any layout page that you have, like application.html.erb if you're implementing this in Rails. There you want to set the boring title, or the one that should get indexed. In addition to that you want to set the meta description and your favicon:




// NextJS code example
<Head>
<meta
name="description"
content="I need to make the computer overlord happy, so: Anes Hodza made this! This is Anes Hodzas' digital property!"
/>
<link rel="icon" href="/favicon.ico" />
<title>Anes Hodzas' personal website</title>
</Head>









Creating the custom titles



Then you want to go to your index page (the one that gets shown on /).

There you want to create a const array with all your titles as strings:




const titles = [
'Ran on my machine',
'Web developer? I think?',
'Engineer is an overstatement',
'I\'m testing this in prod',
'Does anyone read these?',
'I\'m not a robot',
'http://localhost:3000',
'I don\'t use arch, btw'
]






In the case of something like Rails, where the backend logic is somewhat separated from the html code, you would probably put this in the controller.






Sending the user your custom titles



It's very important that the changing page titles are handled in the backend, as otherwise Google starts indexing your webpage weirdly.

In the case of NextJS you would want to create a getServerSideProps function:




export async function getServerSideProps(context) {
// ...
}






Now in there we want to pick the title randomly and return it as a prop:




export async function getServerSideProps(context) {
const index = Math.floor(Math.random() * titles.length);
let title = titles[index];

return {
props: {
index,
title
}
}
}






Now if you start refreshing your page you should see that the title changes.






Fixing Google SEO again, because it's better to be safe than sorry



The Google crawler for some reason sometimes still indexes a random title, so we will also have to change that in the server-side function. What we do first is define a function that checks if the useragent is any google crawler. That we can do as follows:




const isGooglebot = (userAgent) => {
return /(googlebot|google-inspectiontool\/1\.0)/i.test(userAgent);
};






Why not just match any occurrence of Google you might ask. It's just a precaution in case Chrome decides to adapt the word Google into its user agent string.



And now you also have to call the function and return your wanted title in case its the crawler:




export async function getServerSideProps(context) {
const index = Math.floor(Math.random() * titles.length);
let title = titles[index];

let userAgent = context.req.headers['user-agent'] || '';

if (isGooglebot(userAgent)) {
title = "Anes Hodzas' personal website"
}

return {
props: {
index,
title
}
}
}






And after waiting for Google to index your website again, you should be good to go!






Won't this get marked as cloaking?



I had this feature on for two weeks by now and there wasn't any indication of it being marked as cloaking:



Picture of my website being show in the google search results



In case anything happens, I'll keep you updated!

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

ATT&CK-Navigator · IoC-Radar · Exploit-Belege
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Intelligence Digest — kostenlos Täglich die wichtigsten Security-News · jederzeit abbestellbar
Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War diese Seite hilfreich?
0
Jetzt Bewertung abgeben
🟢 Niedrig (1-3.9) 🟡 Mittel (4.0-6.9) 🔴 Hoch (7.0-8.9) Kritisch (9.0-10.0)

Verwandte Story-Cluster & Quellen (Vektor-KI)

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Randomizing pages titles (and having good SEO)

Thematisch verwandte Begriffe: Randomizing, pages, titles, having · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Nächster Beitrag