/Knowledge/sources/honojs__hono/llms-full/ssg-helper-plugins-advanced-plugin-example--44709af49dd1.md

SSG Helper: Plugins > Advanced Plugin Example - hono-docs

SSG Helper: Plugins Advanced Plugin Example Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt advanced p...

SSG Helper: Plugins > Advanced Plugin Example

Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#advanced-plugin-example

Summary

Here's an example of creating a sitemap plugin that generates a sitemap.xml file: ```ts // plugins.ts import fs from 'node:fs/promises' import path from 'node:path' import type { SSGPlugin } from 'hono/ssg' import { DEFAULT_OUTPUT_DIR...

Content

Here's an example of creating a sitemap plugin that generates a sitemap.xml file:

// plugins.ts
import fs from 'node:fs/promises'
import path from 'node:path'
import type { SSGPlugin } from 'hono/ssg'
import { DEFAULT_OUTPUT_DIR } from 'hono/ssg'

export const sitemapPlugin = (baseURL: string): SSGPlugin => {
  return {
    afterGenerateHook: (result, fsModule, options) => {
      const outputDir = options?.dir ?? DEFAULT_OUTPUT_DIR
      const filePath = path.join(outputDir, 'sitemap.xml')
      const urls = result.files.map((file) =>
        new URL(file, baseURL).toString()
      )
      const siteMapText = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map((url) => `<url><loc>${url}</loc></url>`).join('\n')}
</urlset>`
      fsModule.writeFile(filePath, siteMapText)
    },
  }
}

Applying plugins:

Metadata

{
  "chunk_index": 0,
  "citation": "https://hono.dev/llms-full.txt#advanced-plugin-example",
  "coverage_role": "overview",
  "qualified_title": "Hono / llms-full / SSG Helper > Plugins > Advanced Plugin Example (1)",
  "retrieved_at": "2026-07-02T05:51:01Z",
  "section_index": 761,
  "source_id": "/honojs/hono",
  "source_type": "llms_full",
  "target_label": "llms-full",
  "title": "SSG Helper: Plugins > Advanced Plugin Example",
  "upstream_url": "https://hono.dev/llms-full.txt",
  "version": "2026"
}
Kinic Wiki
Loading knowledge node
Details

Identity

database
db_23dhmsxlhukv
database_id
db_23dhmsxlhukv
path
/Knowledge/sources/honojs__hono/llms-full/ssg-helper-plugins-advanced-plugin-example--44709af49dd1.md
kind
directory
role
markdown_note
children
0

Metadata

created_at
virtual
updated_at
virtual
etag
virtual
metadata_json
{}

Lint Hints

No lightweight warnings.

Outgoing Links

No outgoing links indexed.

Incoming Links

Select a file node to inspect backlinks.

Raw Source

No raw source path inferred.