skip to Main Content

I’m building a marketing/consumer site for my company, migrating away from WordPress (thank god) to a combo of Next and Prismic. Currently, our consumer site has about 600 pages to account for multiple product and landing pages for each of our 35+ dealers, but I’d like to move away from managing content for 600 pages, as all of the dealers share pages and content; the only thing that number of pages serves is allowing us to have enhanced SEO and url paths, so that each product page is a sub page of the dealers i.e. san-diego-ca/product-page sacramento-ca/product-page. Hopefully this is enough info to clarify my broader question.

I’m using SSR and getServerSideProps, and I want to be able to have the same sort of URL structure, with each individual dealer having it’s own pages with the specific url path, but they don’t need to have their own page content. It all shares the same stuff. I have a page in Prismic called /interior-doors. With Next is there a way to allow that /interior-doors page to be accessed from mysite.com/interior-doors as well as mysite.com/sacramento-ca/interior-doors without needing to have 2 separate pages?

Thanks in advance, I can add as much code or as many details as necessary.

3

Answers


  1. You can use Next.js rewries for these sort of aliases.

    There is probably more to your content strategy than I can read out from the intial description but generally speaking duplicate content across 600 pages doesn’t sound like you are doing the internet a favour and search engine crawlers might get it at some point too.

    Login or Signup to reply.
  2. Take a look at Next’s redirects: https://nextjs.org/docs/api-reference/next.config.js/redirects

    You can specify, including for dynamic routes, which routes should be ‘redirected’ to where, like so:

    module.exports = {
      async redirects() {
        return [
          {
            source: '/:dealer/:product',
            destination: '/:product'
            permanent: false,
          }
        ]
      }
    }
    

    This results in visits to /sacramento-ca/interior-doors to redirect to /interior-doors, etc. This may not fit your exact use case so please check out the documentation for more details.

    Login or Signup to reply.
  3. You actually should be able to accomplish this with dynamic routes. For your use case of having multiple depths of the URL structure use the same document, optional catch-all routes might make the most sense. You can then pass whatever you need in as the query and then pass that through to the content, for instance:

    interior-doors/[[...slug]].js
    

    Would match: /interior-doors, /interior-doors/sacramento-ca, /post/sacramento-ca/interior-doors

    And then you can access the query and use those parameters in your content if you want, so you could actually pull the city name and use it in a headline or copy.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search