Skip to content

Commit

Permalink
SEO optimised
Browse files Browse the repository at this point in the history
  • Loading branch information
Somnath-Chattaraj committed Oct 13, 2024
1 parent d2be756 commit a887d02
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 2 deletions.
27 changes: 27 additions & 0 deletions frontend/generate-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { SitemapStream, streamToPromise } from 'sitemap';
import { createWriteStream } from 'fs';
import { fileURLToPath } from 'url';
import path from 'path';

// Create __dirname for ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// Resolve the path to sitemap.xml
const sitemapPath = path.resolve(__dirname, 'public', 'sitemap.xml');

const sitemap = new SitemapStream({ hostname: 'https://capusify.site' });

const links = [
{ url: '/', changefreq: 'daily', priority: 1.0 },
{ url: '/about', changefreq: 'weekly', priority: 0.8 },
{ url: '/contact', changefreq: 'monthly', priority: 0.5 }
];

links.forEach(link => sitemap.write(link));
sitemap.end();

// Create the sitemap and handle errors
streamToPromise(sitemap.pipe(createWriteStream(sitemapPath)))
.then(() => console.log('Sitemap created successfully!'))
.catch(err => console.error('Error generating sitemap:', err));
26 changes: 26 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@
<link rel="icon" type="image/svg+xml" href="./src/images/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Campus Chatter</title>
<meta property="og:title" content="Capusify - Your Platform for XYZ" />
<meta property="og:description" content="Offering the best services in XYZ." />
<meta property="og:image" content="https://capusify.site/og-image.jpg" />
<meta property="og:url" content="https://capusify.site" />
<meta property="og:type" content="website" />

<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Capusify - Your Platform for XYZ" />
<meta name="twitter:description" content="Offering the best services in XYZ." />
<meta name="twitter:image" content="https://capusify.site/og-image.jpg" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Capusify",
"url": "https://capusify.site",
"logo": "https://capusify.site/logo.png",
"description": "Your platform for XYZ.",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+1-800-123-456",
"contactType": "Customer Support"
}
}
</script>
</head>
<body>
<div id="root"></div>
Expand Down
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"generate-sitemap": "node generate-sitemap.js"
},
"dependencies": {
"@chakra-ui/react": "^2.8.2",
Expand All @@ -21,11 +22,13 @@
"react": "^18.3.1",
"react-autosuggest": "^10.1.0",
"react-dom": "^18.3.1",
"react-helmet-async": "^2.0.5",
"react-icons": "^5.3.0",
"react-infinite-scroll-component": "^6.1.0",
"react-loader-spinner": "^6.1.6",
"react-router-dom": "^6.26.2",
"react-use-websocket": "^4.8.1",
"sitemap": "^8.0.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
Empty file modified frontend/public/404.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified frontend/public/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Empty file modified frontend/public/vite.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Disallow:

Sitemap: https://capusify.site/sitemap.xml
17 changes: 17 additions & 0 deletions frontend/src/components/homePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ export const Header = () => {

return (
<div className='bg-[#1F2135]'>
<Helmet>
<script type="application/ld+json">
{JSON.stringify({
"@context": "https://schema.org",
"@type": "Organization",
"name": "Capusify",
"url": "https://capusify.site",
"logo": "https://capusify.site/logo.png",
"description": "Your platform for XYZ.",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+1-800-123-456",
"contactType": "Customer Support"
}
})}
</script>
</Helmet>
<nav className="flex justify-between items-center px-6 lg:px-32 py-5">
<div className="text-lg font-bold flex">
<img src={logo} alt="Campus Chatter Logo" className='w-10 h-10 rounded-full mx-3' />
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { HelmetProvider } from 'react-helmet-async';
import App from "./App.jsx";
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
ReactDOM.createRoot(document.getElementById("root")).render(
<HelmetProvider>
<App />
</HelmetProvider>

);

0 comments on commit a887d02

Please sign in to comment.