diff --git a/index.php b/index.php
index 2a30e9f..e0eebf8 100644
--- a/index.php
+++ b/index.php
@@ -18,6 +18,11 @@ if (!isLoggedIn()) {
     setDefaultSessionData();
 }
 
+if($routerRequest["site_name"] == "sitemap.xml") {
+    require "lib/sitemap.php";
+    return generateSitemap();
+}
+
 if ($routerRequest["type"] == "api") {
     echo getEndpoint($routerRequest["site_name"]);
 
diff --git a/lib/router.php b/lib/router.php
index 0b704be..2a74b0d 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -26,6 +26,7 @@ function initRouter(): array
     if($_SERVER["REQUEST_METHOD"] == "POST"){
         $routerRequest["type"] = "api";
     }
+
     if(empty($routerRequest["type"])) {
         $routerRequest["type"] = "page";
     }
diff --git a/lib/sitemap.php b/lib/sitemap.php
new file mode 100644
index 0000000..f99dd4e
--- /dev/null
+++ b/lib/sitemap.php
@@ -0,0 +1,29 @@
+<?php
+require "lib/sitemap.php";
+
+function generateSitemap(): string {
+    global $routerConfig;
+    $site_dirs = array_diff(scandir($routerConfig["page_dir"]), array('.', '..'));
+
+    $sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
+    $sitemap .= '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
+
+    foreach ($site_dirs as $site_dir) {
+        $pages_dir = array_diff(scandir($routerConfig["page_dir"] . $site_dir), array('.', '..'));
+
+        foreach ($pages_dir as $page_file) {
+            $page_file_tmp = explode(".", $page_file);
+            $page_basename = $page_file_tmp[0];
+            $page_location = "/" . $site_dir . "/" . $page_basename;
+
+            $sitemap .= '<url>' . PHP_EOL;
+            $sitemap .= '<loc>' . htmlspecialchars($page_location) . '</loc>' . PHP_EOL;
+            // You can add other optional tags like lastmod, changefreq, priority here if needed
+            $sitemap .= '</url>' . PHP_EOL;
+        }
+    }
+
+    $sitemap .= '</urlset>' . PHP_EOL;
+
+    return $sitemap;
+}
\ No newline at end of file