Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce configurable "sitemap index path" for enhanced plugin compatibility #1936

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

josephfusco
Copy link
Member

Description

This PR introduces a new feature allowing the configuration of a custom sitemap index path via the sitemapIndexPath option in the getSitemapProps function. This is particularly useful for ensuring compatibility with WordPress plugins like RankMath that modify the default sitemap path.

To configure a custom sitemap index path, update your getServerSideProps function in your Next.js page as follows:

import { getSitemapProps } from '@faustwp/core';

export default function Sitemap() {}

export function getServerSideProps(ctx) {
  return getSitemapProps(ctx, {
    sitemapIndexPath: '/sitemap_index.xml', // Specify the custom sitemap index path
    frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
  });
}

This is particularly useful when using WordPress plugins like RankMath that change the default sitemap path from /wp-sitemap.xml to another path, such as /sitemap_index.xml.

Related Issue(s):

Testing

  1. Enable RankMath and ensure it changes the sitemap index path to /sitemap_index.xml.
  2. Update getServerSideProps with sitemapIndexPath: /sitemap_index.xml.
  3. Deploy the application.
  4. Visit /sitemap.xml and verify the sitemap loads correctly.
  5. Confirm all expected URLs are present and no 404 errors occur.

@josephfusco josephfusco requested a review from a team as a code owner August 20, 2024 16:40
Copy link

changeset-bot bot commented Aug 20, 2024

🦋 Changeset detected

Latest commit: f2ce48a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@faustwp/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 20, 2024

📦 Next.js Bundle Analysis for @faustwp/getting-started-example

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link
Member

@theodesp theodesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@theodesp theodesp merged commit 2b7949b into canary Aug 21, 2024
22 checks passed
@theodesp theodesp deleted the fix/1885-custom-sitemap-index branch August 21, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants