Skip to content

Commit

Permalink
Merge pull request #488 from myselfshivams/main
Browse files Browse the repository at this point in the history
closes : #479

added:: Meta Tags, robots.txt, sitemaps for SEO Enhancement
  • Loading branch information
dhairyagothi authored Nov 3, 2024
2 parents 6388226 + ec53d05 commit 9bc306f
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 1 deletion.
22 changes: 22 additions & 0 deletions frontend/generate-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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://stationguide.onrender.com/' });
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);
});
66 changes: 65 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
"react": "^18.3.1",
"react-datepicker": "^7.4.0",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-icons": "^5.3.0",
"react-leaflet": "^4.2.1",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.26.2",
"shadcn-ui": "^0.2.3",
"sitemap": "^8.0.0",
"socket.io-client": "^4.8.0",
"station-saarthi": "file:",
"styled-components": "^6.1.13",
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://stationguide.onrender.com/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://stationguide.onrender.com/</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 @@ -27,11 +27,13 @@ import Error from "./Pages/Error";
import PrivacyPolicy from "./Pages/PrivacyPolicy"; // Added back from one version
import User from "./Pages/User"; // Added from the other version
import ComplainBox from "./Pages/ComplainBox";
import Metadata from "./metadata";

function App() {
return (
<>
<Router>
<Metadata />
<Routes>
<Route path="/" element={<Herosection />} />
<Route path="/Login" element={<LoginPage />} />
Expand Down
45 changes: 45 additions & 0 deletions frontend/src/metadata.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react";

const Metadata = () => {
return (
<>

<title>Station Guide - Your Platform Guide</title>
<meta name="description" content="Station Guide is your go-to resource for navigating platforms with ease. Discover comprehensive guides and tips for a seamless travel experience." />
<meta name="keywords" content="station guide, platform guide, travel tips, navigation, transportation" />
<meta name="author" content="Station Guide Team" />
<meta name="robots" content="index, follow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="canonical" href="https://stationguide.onrender.com" />

<meta property="og:type" content="website" />
<meta property="og:title" content="Station Guide - Your Platform Guide" />
<meta property="og:description" content="Explore Station Guide, your comprehensive resource for platform navigation and travel tips." />
<meta property="og:image" content="URL_TO_IMAGE" />
<meta property="og:url" content="https://stationguide.onrender.com" />
<meta property="og:site_name" content="Station Guide" />
<meta property="og:locale" content="en_US" />

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Station Guide - Your Platform Guide" />
<meta name="twitter:description" content="Your essential guide for navigating platforms with ease." />
<meta name="twitter:image" content="URL_TO_IMAGE" />
<meta name="twitter:site" content="@YourTwitterHandle" />
<meta name="twitter:creator" content="@YourTwitterHandle" />

<meta name="theme-color" content="#4CAF50" />
<meta name="apple-mobile-web-app-title" content="Station Guide" />
<meta name="application-name" content="Station Guide" />
<meta name="msapplication-TileColor" content="#4CAF50" />
<meta name="msapplication-config" content="/browserconfig.xml" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />

<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/manifest.json" />
</>
);
};

export default Metadata;

0 comments on commit 9bc306f

Please sign in to comment.