Skip to content

Commit

Permalink
doc: misc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Nov 1, 2024
1 parent a1d2ce0 commit fd4d031
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 19 deletions.
16 changes: 16 additions & 0 deletions docs/content/0.getting-started/0.introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ navigation:
title: 'Introduction'
---

## Why use Nuxt Sitemap?

Nuxt Sitemap is a module for generating XML Sitemaps with minimal configuration and best practice defaults.

The core output of this module is a [sitemap.xml](https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview) file, which is used by search engines to understand the structure of your site and index it more effectively.

While it's not required to have a sitemap, it can be a powerful tool in getting your content indexed more frequently and more accurately,
especially for larger sites or sites with complex structures.

While it's simple to create your own sitemap.xml file, it can be time-consuming to keep it up-to-date with your site's content
and easy to miss best practices.

Nuxt Sitemap automatically generates the sitemap for you based on your site's content, including lastmod, image discovery and more.

Ready to get started? Check out the [installation guide](/docs/robots/getting-started/installation).

## Features

- 🌴 Single /sitemap.xml or multiple /posts-sitemap.xml, /pages-sitemap.xml
Expand Down
40 changes: 32 additions & 8 deletions docs/content/0.getting-started/1.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,50 @@ navigation:
title: 'Installation'
---

## Module Setup
## Setup Module

Want to know why you might need this module? Check out the [introduction](/docs/sitemap/getting-started/introduction).

To get started with Nuxt Sitemap, you need to install the dependency and add it to your Nuxt config.

:ModuleInstall{name="@nuxtjs/sitemap"}

## Previewing Your Sitemap
## Verifying Installation

After you've set up the module with the minimal config, you should be able to visit [`/sitemap.xml`](http://localhost:3000/sitemap.xml) to see the generated sitemap.

You may notice that the URLs point to your `localhost` domain, this is to make navigating your local site easier, and will be updated when you deploy your site.

All pages preset are discovered from your [Application Sources](/docs/sitemap/getting-started/data-sources), for dynamic URLs see [Dynamic URLs](/docs/sitemap/guides/dynamic-urls).

You can debug this further in Nuxt DevTools under the Sitemap tab.

## Next Steps
## Configuration

At a minimum the module requires a Site URL to be set, this is to only your canonical domain is being used for
the sitemap. A site name can also be provided to customize the sitemap [stylesheet](/docs/sitemap/guides/customising-ui).

:SiteConfigQuickSetup

It's recommended to use this module with Nuxt Robots so that the sitemap paths are automatically added to your robots.txt file.
To ensure search engines find your sitemap, you will need to add it to your robots.txt. It's recommended to use the [Nuxt Robots](/docs/robots/getting-started/installation) module for this.

:ModuleCard{slug="robots" class="w-1/2"}

Other suggestions:
Every site is different and will require their own further unique configuration, to give you a head start:

- [Dynamic URL Endpoint](/docs/sitemap/guides/dynamic-urls) - If you have dynamic URLs you need to add to the sitemap, you can use a runtime API endpoint. For example, if your
generating your site from a CMS.
- [Multi Sitemaps](/docs/sitemap/guides/multi-sitemaps) - If you have 10k+ pages, you may want to split your sitemap into multiple files
so that search engines can process them more efficiently.

You do not need to worry about any further configuration in most cases, check the [best practices](/docs/sitemap/guides/best-practices) guide for more information.

## Next Steps

You've successfully installed Nuxt Sitemap and configured it for your project.

Documentation is provided for module integrations, check them out if you're using them.
- [Nuxt I18n](/docs/sitemap/guides/i18n) - Automatic locale sitemaps.
- [Nuxt Content](/docs/sitemap/guides/content) - Configure your sitemap entry from your markdown.

- You may want to add your own sources, see [Dynamic URLs](/docs/sitemap/guides/dynamic-urls).
- Have 1000's of pages? Consider using [Multiple Sitemaps](/docs/sitemap/guides/multi-sitemaps).
- Ready to go Live? See [Submitting Your Sitemap](/docs/sitemap/guides/submitting-sitemap).
Once you're ready to go live, check out the [Submitting Your Sitemap](/docs/sitemap/guides/submitting-sitemap) guide.
2 changes: 1 addition & 1 deletion docs/content/2.guides/0.data-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Learn how the Nuxt Sitemap sources work.

Every URL within your sitemap will belong to a source.

A source will either be a User source or a Application source.
A source will either be a User source or an Application source.

## Application Sources

Expand Down
2 changes: 2 additions & 0 deletions docs/content/2.guides/0.multi-sitemaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Multi Sitemaps
description: Generate multiple sitemaps for different sections of your site.
---

## Introduction

The module will generate a single `/sitemap.xml` file by default, for most websites this is perfect.

However, for larger sites that start having over thousands of URLs, introducing multiple sitemaps can help
Expand Down
2 changes: 2 additions & 0 deletions docs/content/2.guides/2.dynamic-urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Dynamic URL Endpoint
description: Use runtime API endpoints to generate dynamic URLs for your sitemap.
---

## Introduction

In some instances, like using a CMS, you may need to implement an endpoint to make
all of your site URLs visible to the module.

Expand Down
2 changes: 2 additions & 0 deletions docs/content/2.guides/3.filtering-urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ If you don't want to disable these sources but want to remove these URLs you hav
The easiest way to block search engines from indexing a URL is to use the [Nuxt Robots](/docs/robots/getting-started/installation) module
and simply block the URL in your robots.txt.

:ModuleCard{slug="robots" class="w-1/2"}

Nuxt Sitemap will honour any blocked pages from being ignored in the sitemap.

## Disabling indexing with Route Rules
Expand Down
20 changes: 10 additions & 10 deletions docs/content/5.nitro-api/nitro-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ description: Learn how to use Nitro Hooks to customize your sitemap entries.

Nitro hooks can be added to modify the output of your sitemaps at runtime.

## `sitemap:resolved`
## `'sitemap:resolved'`{lang="ts"}

**Type:** `async (ctx: { urls: SitemapConfig; sitemapName: string }) => void | Promise<void>`
**Type:** `async (ctx: { urls: SitemapConfig; sitemapName: string }) => void | Promise<void>`{lang="ts"}

Triggered once the final structure of the XML is generated, provides the URLs as objects.

```ts [server/plugins/sitemap.ts]
import { defineNitroPlugin } from 'nitropack/runtime/plugin'
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:resolved', async (ctx) => {
Expand All @@ -34,14 +34,14 @@ export default defineNitroPlugin((nitroApp) => {
})
```

## `sitemap:index-resolved`
## `'sitemap:index-resolved'`{lang="ts"}

**Type:** `async (ctx: { sitemaps: { sitemap: string, lastmod?: string }[] }) => void | Promise<void>`
**Type:** `async (ctx: { sitemaps: { sitemap: string, lastmod?: string }[] }) => void | Promise<void>`{lang="ts"}

Triggered once the final structure of the sitemap index is generated, provides the sitemaps as objects.

```ts [server/plugins/sitemap.ts]
import { defineNitroPlugin } from 'nitropack/runtime/plugin'
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:index-resolved', async (ctx) => {
Expand All @@ -54,15 +54,15 @@ export default defineNitroPlugin((nitroApp) => {
})
```

## `sitemap:output`
## `'sitemap:output'`{lang="ts"}

**Type:** `async (ctx: { sitemap: string; sitemapName: string }) => void | Promise<void>`
**Type:** `async (ctx: { sitemap: string; sitemapName: string }) => void | Promise<void>`{lang="ts"}

Triggered before the sitemap is sent to the client.
It provides the sitemap as a XML string.

```ts [server/plugins/sitemap.ts]
import { defineNitroPlugin } from 'nitropack/runtime/plugin'
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:output', async (ctx) => {
Expand All @@ -80,7 +80,7 @@ For some search engines, you may need to add a custom `xmlns` attribute to the s
search and replace in the `sitemap:output` hook.

```ts [server/plugins/sitemap.ts]
import { defineNitroPlugin } from 'nitropack/runtime/plugin'
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:output', async (ctx) => {
Expand Down

0 comments on commit fd4d031

Please sign in to comment.