Skip to content

Commit

Permalink
added:: Meta Tags, robots.txt, sitemaps for SEO Enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
myselfshivams committed Nov 2, 2024
1 parent e5d522e commit 3e6e763
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
21 changes: 21 additions & 0 deletions frontend/generate-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SitemapStream } from 'sitemap';
import { createWriteStream } from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const pages = [
{ url: '/', changefreq: 'daily', priority: 1.0 },
];
async function generateSitemap() {
const writeStream = createWriteStream(path.resolve(__dirname, 'public', 'sitemap.xml'));
const sitemap = new SitemapStream({ hostname: 'https://play-cafe.vercel.app/' });
sitemap.pipe(writeStream).on('finish', () => {
console.log('Sitemap generated successfully');
});
pages.forEach(page => sitemap.write(page));
sitemap.end();
}
generateSitemap().catch(error => {
console.error('Error generating sitemap:', error);
});
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
"lucide-react": "^0.454.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-icons": "^5.2.1",
"react-intersection-observer": "^9.13.0",
"react-lazy-load-image-component": "^1.6.2",
"react-pageflip": "^2.0.3",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.24.1",
"sitemap": "^8.0.0",
"split-type": "^0.3.4",
"tailwind-merge": "^2.5.2",
"tailwindcss": "^3.4.4",
Expand Down
4 changes: 4 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Disallow: /private
Allow: /
Sitemap: https://play-cafe.vercel.app/sitemap.xml
1 change: 1 addition & 0 deletions frontend/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://play-cafe.vercel.app/</loc><changefreq>daily</changefreq><priority>1.0</priority></url></urlset>
2 changes: 2 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import Footer from '../src/components/Shared/Footer';
import { Outlet } from 'react-router-dom';
import BackToTopButton from './components/Shared/BackToTopButton';
import Preloader from './components/Preloader';
import Metadata from './components/Metadata';


function App() {
return (
<>
<Metadata />
<Preloader />
<BackToTopButton />
<Navbar />
Expand Down
44 changes: 44 additions & 0 deletions frontend/src/metadata.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Helmet } from 'react-helmet';

const Metadata = () => {
return (
<Helmet>
<title>Play Cafe - Where Board Games Meet Great Food</title>

<meta name="description" content="Play Cafe offers a warm and exciting environment for board game enthusiasts to gather, relax, and enjoy great food." />

<meta name="keywords" content="cafe, board games, food, gaming, cafe near me, snacks, beverages, fun activities" />

<meta name="author" content="Play Cafe" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

{/* Open Graph Tags */}
<meta property="og:title" content="Play Cafe - Where Board Games Meet Great Food" />
<meta property="og:description" content="Join us at Play Cafe for a fun and immersive experience with board games and delicious food!" />
<meta property="og:image" content="URL to image for sharing" />
<meta property="og:url" content="https://play-cafe.vercel.app" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Play Cafe" />

{/* Twitter Card Tags */}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Play Cafe - Where Board Games Meet Great Food" />
<meta name="twitter:description" content="Play Cafe offers a warm and exciting environment for board game enthusiasts to gather, relax, and enjoy great food." />
<meta name="twitter:image" content="URL to image for sharing" />
<meta name="twitter:site" content="@YourTwitterHandle" />


<link rel="canonical" href="https://play-cafe.vercel.app" />

<meta name="robots" content="index, follow" />

<meta name="theme-color" content="#ffffff" />
<meta name="rating" content="General" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
</Helmet>
);
};

export default Metadata;

0 comments on commit 3e6e763

Please sign in to comment.