DocumentationLogin
Enterspeed logo

Sitemap

Enterspeed patterns

Sitemaps are an essential component of any website. They serve as a blueprint for search engines to navigate and index the pages on your site. A sitemap should include all the important pages on your website, including pages that may not be easily discovered through typical navigation.

There are two types of sitemaps: XML sitemaps and HTML sitemaps. XML sitemaps are designed specifically for search engines and are usually submitted to search engines through their webmaster tools. HTML sitemaps, on the other hand, are designed for human visitors and are often linked to from the footer of a website.

A sitemap should include all the pages on your website that you want to be indexed by search engines. This includes your homepage, category pages, product pages, and any other important pages. It is also important to include any page that may be difficult to find through typical navigation, such as pages that are only accessible through a search bar or pages that require users to log in.

In addition to including the important pages on your website, your sitemap should also provide additional information about each page. This can include the last time the page was updated, the priority of the page, and the frequency with which the page is updated.

How to implement with Enterspeed

We recommend using our Routes API to generate your XML sitemap. The Routes API is what you use to GET all available routes for a specific environment.

You can use the Routes API to generate an XML sitemap. Below is an example of how to create an XML sitemap using the sitemap-package.

1// JavaScript example of how to dynamically create a sitemap.xml based on routes in Enterspeed
2
3import axios, { AxiosResponse } from "axios";
4import { createWriteStream } from "fs";
5import { SitemapStream } from "sitemap";
6import { IRoutesResponse } from "./enterspeed-types";
7
8const getRoutes = async (continuationToken = null) => {
9  if (
10    !process.env.ENTERSPEED_API_PATH ||
11    !process.env.ENTERSPEED_PRODUCTION_ENVIRONMENT_API_KEY
12  ) {
13    return null;
14  }
15
16  const headers = {
17    "X-Api-Key": process.env.ENTERSPEED_PRODUCTION_ENVIRONMENT_API_KEY,
18  };
19
20  const routesParams = new URLSearchParams();
21  routesParams.append("first", "100");
22  if (continuationToken) {
23    routesParams.append("continuationToken", continuationToken);
24  }
25
26  const routesReqUrl = new URL(process.env.ENTERSPEED_API_PATH + "/routes/v2");
27  routesReqUrl.search = routesParams.toString();
28
29  const routesReq: AxiosResponse<IRoutesResponse> = await axios.get(
30    routesReqUrl.toString(),
31    {
32      headers,
33    }
34  );
35
36  return routesReq.data;
37};
38
39export const generateEnterspeedSitemap = async () => {
40  const sitemap = new SitemapStream({
41    hostname: process.env.DOMAIN,
42  });
43
44  const writeStream = createWriteStream("./public/sitemap.xml");
45  sitemap.pipe(writeStream);
46
47  let continuationToken = null;
48  do {
49    const routesData = await getRoutes(continuationToken);
50    if (!routesData) {
51      break;
52    }
53
54    const { continuationToken: newToken, results } = routesData;
55    continuationToken = newToken;
56
57    results.forEach((x) => {
58      sitemap.write({
59        url: x.url,
60        lastmod: new Date(x.updatedAt).toISOString(),
61      });
62    });
63  } while (continuationToken);
64
65  sitemap.end();
66};

Ready to try out Enterspeed? 🚀

Start combining & connecting your services today

Product

Why Enterspeeed?Use casesBuild vs. buyIntegrations

Company

Partners ☕ Let's talk!About UsContact UsTerms of ServicePrivacy PolicySecurity
Enterspeed logo

© 2020 - 2024 Enterspeed A/S. All rights reserved.

Made with ❤️ and ☕ in Denmark.