diff --git a/apps/blog/astro.config.js b/apps/blog/astro.config.js
index 12e5cd4c..bea7d14c 100644
--- a/apps/blog/astro.config.js
+++ b/apps/blog/astro.config.js
@@ -28,4 +28,4 @@ export default defineConfig({
markdown: {
remarkPlugins: [remarkPlugin],
},
-});
+});
\ No newline at end of file
diff --git a/apps/blog/package.json b/apps/blog/package.json
index 3de1745b..70044878 100644
--- a/apps/blog/package.json
+++ b/apps/blog/package.json
@@ -5,6 +5,7 @@
"dependencies": {
"@astrojs/react": "^4.1.2",
"@astrojs/rss": "^4.0.11",
+ "@astrojs/sitemap": "^3.2.1",
"@astrojs/tailwind": "^5.1.4",
"@astrojs/vercel": "^8.0.1",
"@crocoder-dev/remark-plugin": "*",
diff --git a/apps/blog/public/robots.txt b/apps/blog/public/robots.txt
new file mode 100644
index 00000000..282b669d
--- /dev/null
+++ b/apps/blog/public/robots.txt
@@ -0,0 +1,4 @@
+User-agent: *
+Allow: /
+
+Sitemap: https://crocoder.dev/blog/sitemap.xml
\ No newline at end of file
diff --git a/apps/blog/src/layouts/head.astro b/apps/blog/src/layouts/head.astro
index 256334b3..67371f30 100644
--- a/apps/blog/src/layouts/head.astro
+++ b/apps/blog/src/layouts/head.astro
@@ -50,7 +50,7 @@ const allPartialsPlainText = (
const sufix = import.meta.env.DEV ? "" : "blog/";
-const siteUrl = import.meta.env.SITE_URL + sufix;
+const siteUrl = import.meta.env.PUBLIC_SITE_URL + sufix;
const posts = await getCollection("posts");
const currentPost = posts.find((post) => post.slug === slug);
diff --git a/apps/blog/src/pages/sitemap.xml.ts b/apps/blog/src/pages/sitemap.xml.ts
new file mode 100644
index 00000000..3feb51ed
--- /dev/null
+++ b/apps/blog/src/pages/sitemap.xml.ts
@@ -0,0 +1,47 @@
+import { getCollection } from "astro:content";
+const markdownPosts = await getCollection("posts");
+
+const prefix = import.meta.env.DEV ? "/" : "/blog";
+const siteUrl = import.meta.env.PUBLIC_SITE_URL + (prefix === "/" ? "" : prefix);
+
+export function GET() {
+ const posts = [
+ ...markdownPosts.map((post: any) => ({
+ url: `${siteUrl}/${post.slug}`,
+ createdAt: post.data.createdAt
+ ? new Date(post.data.createdAt)
+ : new Date(),
+ imageUrl: `${siteUrl}${post.data.image}`,
+ })),
+ ];
+
+ posts.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
+
+ const urls = posts
+ .map(
+ (post) => `
+