Metadata Learn how to customize metadata for your MkSaaS website
This guide covers the metadata system in your MkSaaS website, how to customize SEO-related information, and how to configure social sharing metadata for optimal visibility.
The MkSaaS template comes with a robust metadata system that provides:
SEO-optimized page titles and descriptions
Social media sharing metadata (Open Graph and Twitter)
Favicon and app icons
Internationalization support for metadata
The metadata system in MkSaaS is built on Next.js metadata API and is configured through several key files:
The main website configuration is defined in src/config/website.tsx:
export const websiteConfig : WebsiteConfig = {
metadata: {
theme: {
defaultTheme: 'default' ,
enableSwitch: true ,
},
mode: {
defaultMode: 'dark' ,
enableSwitch:
This configuration defines:
Default theme and dark mode settings
Logo and Open Graph image paths
Social media official account links
The basic website metadata such as name, title, and description are defined in the translation files:
{
"Metadata" : {
"name" : "MkSaaS" ,
"title" : "MkSaaS - The Best AI SaaS Boilerplate" ,
"description" : "MkSaaS is the best AI SaaS boilerplate. Make AI SaaS in days, simply and effortlessly"
},
// Other translations...
} The constructMetadata function in src/lib/metadata.ts can create the metadata object for each page:
export function constructMetadata ({
title ,
description ,
canonicalUrl ,
image ,
noIndex = false ,
} : {
title ?: string ;
Setting default values from translations
Configuring Open Graph and Twitter card metadata
Setting up favicon and icon information
Managing canonical URLs and robots directives
To change the basic website information like name, title, and description:
Edit the messages/en.json file:
{
"Metadata" : {
"name" : "Your Website Name" ,
"title" : "Your Website Title - Tagline" ,
"description" : "A detailed description of your website for SEO purposes"
}
} For multilingual websites, update each language file with appropriate translations:
{
"Metadata" : {
"name" : "您的网站名称" ,
"title" : "您的网站标题 - 标语" ,
"description" : "您网站的详细描述,用于 SEO 目的"
}
} To change the Open Graph image and logos:
Place your image files in the public directory
Update the paths in src/config/website.tsx:
metadata : {
// Other settings...
images : {
ogImage : '/your-og-image.png' , // Used for social sharing
logoLight : '/your-logo-light.png' , // Logo for light mode
logoDark : '/your-logo-dark.png' , // Logo for dark mode
},
OG Image : 1200×630 pixels for optimal display on social platforms
Logo : At least 512×512 pixels for high-resolution displays
Update your social media official account links in the website configuration:
metadata : {
// Other settings...
social : {
github : 'https://github.com/YourUsername' ,
twitter : 'https://x.com/YourHandle' ,
discord : 'https://discord.gg/YourInvite' ,
youtube : 'https://www.youtube.com/@YourChannel' ,
To replace the default favicons and app icons:
Generate a complete set of icons using a tool like Real Favicon Generator
Place the generated files in the public directory
Update the paths in the constructMetadata function if necessary:
icons : {
icon : '/favicon.ico' ,
shortcut : '/favicon-32x32.png' ,
apple : '/apple-touch-icon.png' ,
}, For pages with multiple URLs or to prevent duplicate content issues, set canonical URLs:
For pages you don't want indexed by search engines:
In your MDX content pages (blog posts, docs, etc.), you can define metadata in the frontmatter:
content/blog/example-post.mdx ---
title: Example Blog Post
description: This is an example blog post with custom metadata
image: /images/blog/example-post.png
---
Content goes here... The metadata system will automatically use these values when rendering the page.
For React pages, you can use the constructMetadata function:
src/app/[locale]/example/page.tsx For pages that need specific Open Graph data:
Keep Titles Concise : Aim for titles under 60 characters for optimal display in search results
Descriptive Meta Descriptions : Write compelling descriptions of 150-160 characters
Unique Content : Ensure each page has unique title and description
Use High-Quality Images : Create professional, relevant images for OG and Twitter cards
Include Keywords : Incorporate relevant keywords naturally in titles and descriptions
Update Consistently : Keep metadata current with your content changes
Mobile Optimization : Ensure your metadata looks good on mobile devices
Now that you understand how to customize metadata in MkSaaS, explore these related topics:
true
,
},
images: {
ogImage: '/og.png' ,
logoLight: '/logo.png' ,
logoDark: '/logo-dark.png' ,
},
social: {
github: 'https://github.com/MkSaaSHQ' ,
twitter: 'https://x.com/mksaascom' ,
discord: 'https://mksaas.link/discord' ,
youtube: 'https://www.youtube.com/@MkSaaS' ,
},
},
// Other configuration sections...
};
description ?: string ;
canonicalUrl ?: string ;
image ?: string ;
noIndex ?: boolean ;
} = {}) : Metadata {
title = title || defaultMessages.Metadata.name;
description = description || defaultMessages.Metadata.description;
image = image || websiteConfig.metadata.images?.ogImage;
const ogImageUrl = new URL ( `${ getBaseUrl () }${ image }` );
return {
title,
description,
alternates: canonicalUrl
? {
canonical: canonicalUrl,
}
: undefined ,
openGraph: {
type: 'website' ,
locale: 'en_US' ,
url: canonicalUrl,
title,
description,
siteName: title,
images: [ogImageUrl. toString ()],
},
twitter: {
card: 'summary_large_image' ,
title,
description,
images: [ogImageUrl. toString ()],
site: getBaseUrl (),
},
icons: {
icon: '/favicon.ico' ,
shortcut: '/favicon-32x32.png' ,
apple: '/apple-touch-icon.png' ,
},
metadataBase: new URL ( getBaseUrl ()),
manifest: `${ getBaseUrl () }/manifest.webmanifest` ,
... (noIndex && {
robots: {
index: false ,
follow: false ,
},
}),
};
}
}
// Add other social platforms as needed
},
}
metadata
=
constructMetadata
({
title: 'Example Page' ,
description: 'Description' ,
canonicalUrl: 'https://=YOUR-DOMAIN.com/preferred-path' ,
});
metadata
=
constructMetadata
({
title: 'Private Page' ,
description: 'This page is not for search engines' ,
noIndex: true ,
});
{ constructMetadata }
from
'@/lib/metadata'
;
export const metadata = constructMetadata ({
title: 'Example Page' ,
description: 'This is an example page with custom metadata' ,
image: '/images/example-page.png' ,
});
from
'next'
;
import { constructMetadata } from '@/lib/metadata' ;
export const metadata : Metadata = {
... constructMetadata ({
title: 'Custom Page' ,
description: 'Description' ,
}),
openGraph: {
type: 'article' ,
publishedTime: '2023-01-01T00:00:00.000Z' ,
authors: [ 'Author Name' ],
// Other article-specific fields
},
};
Website Configuration Configure website settings
Metadata | MkSaaS - Make Your AI SaaS Product in a Weekend