Skip to content

xstevenyung/fresh-seo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fresh SEO

Create Sitemap for your next Fresh project.

Getting started

To get started, run the init command at the root of your project

deno run --allow-read --allow-write https://deno.land/x/fresh_seo/init.ts

You should now have a new file ./routes/sitemap.xml.ts;

You should now have a basic sitemap.xml available at http://localhost:8000/sitemap.xml.

How does it work?

Fresh SEO automatically map out static routes in your Fresh project so you don't have to do anything for basic routes.

But you will still have to map dynamic routes yourself.

// ./routes/sitemap.xml.ts
import { Handlers } from "$fresh/server.ts";
import manifest from "../fresh.gen.ts";
import { SitemapContext } from "https://deno.land/x/fresh_seo/mod.ts";

export const handler: Handlers = {
  GET(req, ctx) {
    const sitemap = new SitemapContext(
      "http://example.com"
      manifest
    );

    // You can add additional page here
+   sitemap.add("/blog/hello-world");

    return sitemap.render();
  },
};

Testing

You can run the test suite using deno task test.

About

The fastest way ⚡️ to create sitemap and robots.txt in your Deno Fresh project 🍋

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published