When Wappler first introduced the routing system for NodeJS, I put forward the idea of improving the routing system to allow for the inclusion of the page title and page description. This so that the content pages will have their own dynamically inserted data.
Having gone through this video - which is great! - and the discussion on the topic, it has left me wondering why not simplify the process of adding dynamic SEO for the content pages.
I have finally managed to refine the process - with the aid of Claude Sonnet 4.6 - by changing the routes.json file as follows:
{
"layouts": {
"main": {
"meta": [
{
"type": "text",
"name": "page_title"
},
{
"type": "text",
"name": "page_description"
},
{
"type": "text",
"name": "page_path"
}
]
}
},
"routes": [
{
"path": "/",
"page": "index",
"layout": "main",
"routeType": "page",
"data": {
"page_title": "Professional Web Design & Hosting Melbourne",
"page_description": "Pleysier Web Solutions — affordable, professional web design, development and hosting for individuals and small to medium businesses. Based in Melbourne, Australia with over 20 years experience.",
"page_path": "/"
}
},
{
"path": "/services",
"page": "services",
"layout": "main",
"data": {
"page_title": "Our Services — Web Development, Hosting & Design",
"page_description": "Comprehensive web solutions including custom web development, reliable Australian hosting and modern responsive design. Tailored for small to medium businesses.",
"page_path": "/services"
}
},
{
"path": "/about",
"page": "about",
"layout": "main",
"data": {
"page_title": "About Us — 20+ Years of Web Development Experience",
"page_description": "Learn about Pleysier Web Solutions — a Melbourne-based web development company with over 20 years experience delivering affordable, quality websites for small businesses.",
"page_path": "/about"
}
},
{
"path": "/contact",
"page": "contact",
"layout": "main",
"data": {
"page_title": "Contact Us — Get a Free Quote",
"page_description": "Get in touch with Pleysier Web Solutions for a free, no-obligation quote on web design, development or hosting. Melbourne-based with personalised service.",
"page_path": "/contact"
}
}
]
}
It then comes down to simply adding the relevant code in the <head> section as in:
<!-- SEO Meta -->
<meta name="description" content="<%=_('page_description.default("Pleysier Web Solutions — affordable, professional web design, development and hosting for individuals and small to medium businesses.")', locals)%>">
<link rel="canonical" href="https://pleysier.com.au<%=_('page_path.default("/")', locals)%>">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Pleysier Web Solutions">
<meta property="og:title" content="<%=_('page_title.default("Professional Web Solutions")', locals)%> | Pleysier Web Solutions">
<meta property="og:description" content="<%=_('page_description.default("Pleysier Web Solutions — affordable, professional web design, development and hosting for individuals and small to medium businesses.")', locals)%>">
<meta property="og:url" content="https://pleysier.com.au<%=_('page_path.default("/")', locals)%>">
<title><%=_('page_title.default("Professional Web Solutions")', locals)%> | Pleysier Web Solutions</title>