Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-sitemap

Small helper which scans your Svelte routes folder and generates static sitemap.xml

  • 2.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
increased by27.47%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Package License Build & Publish

Svelte sitemap.xml generator

Small helper which scans your Svelte routes and generates sitemap.xml

Install

npm install svelte-sitemap --save-dev
# yarn add svelte-sitemap --dev

Usage

Use this library as a postbuild hook in your package.json file.

File: package.json

{
  "name": "my-awesome-project",
  "scripts": {
    "postbuild": "npx svelte-sitemap --domain https://myawesomedomain.com"
  }
}

It scans your routes in build/ folder and generates build/sitemap.xml file.

Alternative usage: TypeScript or JavaScript method

Sometimes it can be useful to call the script directly from JavaScript or TypeScript. Of course there is also this option, but in most cases you will need the CLI method as a postbuild hook.

File my-script.js:

import { createSitemap } from 'svelte-sitemap/src/index.js';

createSitemap('https://example.com', { debug: true });

And now you can run your script like this: node my-script.js

⚙️ Options

OptionDescriptionDefaultExample
--domain, -dUse your domain [required]--d https://mydomain.com
--out-dir, -oSet custom build folderbuild-o dist
--ignore, -iIgnore files or folders[]-i '**/admin/**' -i 'my-secret-page'
--trailing-slashes, -tAdd trailing slashesfalse--trailing-slashes
--reset-time, -rSet lastModified time to nowfalse-r
--change-freq, -cSet change frequency Option---change-freq daily
--help, -hDisplay this usage info--v
--version, -vShow version--h
--debugShow some useful logs---debug

🙋 FAQ

How to exclude directory?

Let's say we want to ignore all admin folders and subfolders + just one exact page pages/my-secret-page

npx svelte-sitemap --domain https://www.example.com --ignore 'pages/my-secret-page' --ignore '**/admin/**'

Ping Google Search Console

Every time I deploy a new version, I want to inform Google that there is a new update.

See this discussion with very useful tips.

Error: Missing folder

× Folder 'build/' doesn't exist. Make sure you are using this library as 'postbuild' so 'build/' folder was successfully created before running this script.

  • Make sure your output folder exists. If it has other name than the default build, you can use the outDir (--out-dir) option.
Vercel apdatper
  • If you are using Vercel hosting and adapter-vercel you'll probably want to use it like this:
npx svelte-sitemap --out-dir .vercel/output/static --domain https://www.example.com

Or check out other solutions and join the discussion.

Error: Missing html files

× There is no static html file in your 'build/' folder. Are you sure you are using Svelte adapter-static with prerender option?

This library is intended for the static adapter and prerender option (SSG). So if there are no static files, then my library will not work for you :/

⭐️ Show your support

Give a ⭐️ if this project helped you!

Or if you are brave enough consider making a donation for some 🍺 or 🍵 ;)

🕵️ Privacy Policy

I DO NOT STORE ANY DATA. PERIOD.

I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.

That's why, with this library, what happens on your device stays on your device till disappear.

🤝 Contributing

I welcome you to customize this according to your needs ;)

Pull requests for any improvements would be great!

Feel free to check issues page.

Developing and debugging this library

git clone git@github.com:bartholomej/svelte-sitemap.git
cd svelte-sitemap
yarn
yarn start
Run demo locally

You can find and modify it in ./demo.ts file

yarn demo

🙏 Credits

📝 License

Copyright © 2023 Lukas Bartak

Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)

All contents are licensed under the MIT license.

Keywords

FAQs

Package last updated on 11 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc