---
title: "JSS Next.jsアプリでビルドタイムの静的パスをカスタマイズできます"
slug: "customize-build-time-static-paths-in-jss-next-js-apps"
abstract: "カスタムサイトマップフェッチャーで、静的に生成された動的ルートの返される静的パスを制御します。"
---
# JSS Next.jsアプリでビルドタイムの静的パスをカスタマイズできます

多くのページや商品、記事を持つ大規模なウェブサイトでは、すべてのページの静的生成に時間がかかることがあります。静的生成の一部のページやアイテムを除外することで、静的生成アプリケーションのビルド時間を短縮できます。

これは、SitecoreSitemapFetcherクラス内で初期化・使用されているGraphQLSitemapService/MultisiteGraphQLSitemapServiceインスタンスを修正することで実現できます。

> !重要パフォーマンスの理由から、手動で含める・除外できるパスの数は[Edgeによって制限](https://doc.sitecore.com/xp/ja/developers/hd/21/sitecore-headless-development/limitations-and-restrictions-of-experience-edge-for-xm.html "Limitations and restrictions of Experience Edge for XM")されています。この制限を超えるクエリはGraphQLエラーを返します。

JSS Next.jsアプリでビルド時の静的パスをカスタマイズするには:

-   レンダリングアプリケーションフォルダのsrc/lib/sitemap-fetcher/plugins/graphql-sitemap-service.tsファイル内で、GraphqlSitemapServicePlugin構造体を次のように修正します:
    
    > !注Next.jsマルチサイトアドオンを使用する場合、siteName: config.jssAppNameの代わりに、サイトリゾルバsites: ...new Set(siteResolver.sites.map((site: SiteInfo) => site.name))からサイトのリストを提供します。
    
    -   パスを含めるには、GraphQLSitemapServiceインスタンスのincludedPathsパラメータにパスの配列を提供します。includedPathsを指定すると、クエリは提供されたパターンに一致するパスのみを返します。例えば、/products/で始まるすべてのパスを含める場合:
        
        constructor() {
         this.\_graphqlSitemapService = new GraphQLSitemapService({
         endpoint: config.graphQLEndpoint,
         apiKey: config.sitecoreApiKey,
         siteName: config.jssAppName,
         includedPaths: "/products/"
         });
        }
        
    -   パスを除外するには、GraphQLSitemapServiceインスタンスのexcludedPathsパラメータへのパス配列を提供します。例えば、/products/で始まるパスを含めるには、古い電話に関するパスは除きます:
        
        constructor() {
         this.\_graphqlSitemapService = new GraphQLSitemapService({
         endpoint: config.graphQLEndpoint,
         apiKey: config.sitecoreApiKey,
         siteName: config.jssAppName,
         includedPaths: "/products/",
         excludedPaths: "/products/old-phones/"
         });
        }
        
    -   一部の経路を除くすべての経路を取得するには、excludedPathsパラメータのみを使用できます。例えば、積のすべての経路を除外する場合:
        
        constructor() {
         this.\_graphqlSitemapService = new GraphQLSitemapService({
         endpoint: config.graphQLEndpoint,
         apiKey: config.sitecoreApiKey,
         siteName: config.jssAppName,
         exludedPaths: "/products/"
         });
        }