An open API service indexing awesome lists of open source software.

https://github.com/lelabdev/gositemap

A blazing-fast, test-driven sitemap.xml generator for static SvelteKit sites. SEO-ready, TOML-configurable, and CI/CD friendly
https://github.com/lelabdev/gositemap

Last synced: 4 months ago
JSON representation

A blazing-fast, test-driven sitemap.xml generator for static SvelteKit sites. SEO-ready, TOML-configurable, and CI/CD friendly

Awesome Lists containing this project

README

          

# GoSitemap [![GitHub release](https://img.shields.io/github/v/release/lelabdev/gositemap)](https://github.com/lelabdev/gositemap/releases/latest)

**GoSitemap** is a fast and minimal sitemap generator tailored for static **SvelteKit** sites.
It’s built with simplicity, performance, and automation in mind β€” perfect for CI/CD or local use.

---

## πŸ”₯ What It Does

- Scans your SvelteKit `src/routes/` folder for all **static pages**
- Parses `.md` and `.svx` articles in `src/lib/content/` or any folder you define
- Builds a clean `sitemap.xml` with `` and optional ``
- Uses a single config file: `gositemap.toml` (can be auto-generated on first run)
- Outputs a ready-to-serve `static/sitemap.xml`
- 100% static, no server needed
- Built in Go β€” fast, lightweight, and dependency-free

---

## πŸ›  How to Use

1. Put a `gositemap.toml` at your project root
(or just run the tool and it’ll ask you interactively)

2. Run GoSitemap:

```sh
go run .
# or build:
go build && ./gositemap

```

3. Your sitemap will be created at:

static/sitemap.xml

---

βš™οΈ CLI Options

`--help`, `-h` Show help and example config, then exit
`--dry-run` Output sitemap to stdout only
`--quiet` Suppress logs except errors
`preserve_existing` (in `gositemap.toml`) Controls how existing sitemap.xml files are handled.

---

## πŸ”„ Sitemap Overwrite Behavior (`preserve_existing`)

GoSitemap offers flexible control over how it updates your `sitemap.xml` file:

- **Default Behavior (or `preserve_existing = true` in `gositemap.toml`):**
If a `sitemap.xml` file already exists, GoSitemap will **add only new entries** to it. Existing entries (and their `` dates) will be preserved and *not* updated. This is ideal for incremental updates where you want to maintain historical `` values.

- **Explicit Overwrite (`preserve_existing = false` in `gositemap.toml`):**
If `preserve_existing` is explicitly set to `false`, GoSitemap will **regenerate the entire `sitemap.xml` file**. All entries, including existing ones, will have their `` dates updated based on the current scan. Use this when you want a fresh sitemap reflecting the latest modification times for all content.

---

🧠 Example gositemap.toml

```toml
base_url = "https://yoursite.com"
preserve_existing = true # Set to false to overwrite all entries and update lastmod dates

[content_types]
blog = "src/lib/content"
portfolio = "src/lib/portfolio"

# You can also use glob patterns to specify content directories.
# The slug will be the basename of the directory.
[[glob]]
paths = [
"src/content/*"
]

[changefreq]
blog = "weekly"
portfolio = "monthly"
about = "yearly"

exclude = [
"/admin",
"/secret"
]
```

---

✨ Sample Output

```xml


https://yoursite.com/
2023-07-01


https://yoursite.com/blog/article1
2023-07-01
weekly

```

---

🧩 How It Works

Static pages: Finds all `+page.svelte` or `article.md` files in `src/routes/`

Articles: Includes `.md` / `.svx` from `content_types` folders

Exclusions: Ignores dynamic/param folders and anything in `exclude`.

- If an exclusion starts with `/`, it's treated as a full path prefix (e.g., `/admin` excludes `/admin` and `/admin/users`).
- Otherwise, it matches any directory segment in the URL (e.g., `(flow)` excludes `/blog/(flow)/post`).

lastmod: Uses `publishDate` (if found) or file mtime

changefreq: Defaults to never, customizable via [changefreq]

URL Order: Root β†’ top-level pages β†’ articles β†’ subpages

---

## πŸ“₯ Installation

Download the binary for your OS from the [latest release](https://github.com/lelab/GoSitemap/releases/latest),
then make it executable (on Linux/macOS):

```sh
chmod +x gositemap
./gositemap
```

---

πŸ“¦ Downloads

Grab the latest release:
➑️ [Latest Release](https://github.com/lelabdev/gositemap/releases/latest)

Each binary is compiled with optimizations for minimal size.
The version is embedded directly into the binary (-ldflags), no suffix needed.

---

βœ… Requirements

Go 1.21 or newer

SvelteKit static site structure (uses /static, /routes, etc.)

---

πŸ€” Why GoSitemap?

Super light, no runtime dependencies

No YAML/JSON mess β€” config is TOML and explicit

CLI-first: works locally or in your CI

Clean, readable sitemap output

Works out of the box with SvelteKit projects

---

πŸ’¬ FAQ

How do I change the per type?
Use the [changefreq] section in your TOML.

My page is missing from the sitemap!
Check if it’s dynamic (e.g. [slug]), in parentheses, or listed in exclude.

How to rename /blog/ to something else?
Just change the key in [content_types]:

articles = "src/lib/content"

β†’ This gives /articles/my-post.

My base_url is invalid!
It should start with http:// or https://, and no trailing slash.

---

πŸͺͺ License

MIT

---

Built for real-world static SvelteKit sites.
Scriptable. Predictable. No fluff.