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

GitAuto: Make our sitemap dynamically updated using a library #172

Merged
merged 12 commits into from
Jan 5, 2025

Conversation

gitauto-for-dev[bot]
Copy link

Resolves #167

What is the feature

Implement a dynamically updated sitemap by integrating a sitemap generation library. This ensures that the sitemap reflects the latest content automatically, improving SEO and user navigation without manual updates.

Where / How to code and why

  1. Library Selection:

    • Use the next-sitemap library, which is specifically designed for Next.js applications and supports dynamic sitemap generation.
  2. Installation:

    • Add next-sitemap to the project dependencies by running:
      npm install next-sitemap
      
  3. Configuration:

    • Create a next-sitemap.js file in the root directory with the necessary configuration:
      module.exports = {
        siteUrl: 'https://www.yourwebsite.com',
        generateRobotsTxt: true,
        // Additional configurations as needed
      };
  4. Update Build Process:

    • Modify the package.json scripts to include sitemap generation during the build process:
      "scripts": {
        "build": "next build && next-sitemap"
      }
  5. Remove Static Sitemap:

    • Delete the existing app/sitemap.xml to avoid conflicts with the dynamically generated sitemap.
  6. Testing:

    • Build the project and verify that the sitemap is correctly generated at the expected location.
    • Ensure that the sitemap updates automatically with new content additions.
  7. Deployment:

    • Deploy the changes to the production environment and confirm that search engines can access the updated sitemap.

Why:
Using next-sitemap leverages Next.js capabilities for automatic sitemap generation, ensuring scalability and reducing maintenance overhead. Removing the static sitemap eliminates the risk of outdated content being indexed.

Anything the issuer needs to do

No action required.

Test these changes locally

git fetch origin
git checkout gitauto-wes/issue-167-20250103-221343
git pull origin gitauto-wes/issue-167-20250103-221343

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitauto-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 1:47pm

package.json Outdated
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "next build && next-sitemap",
Copy link
Contributor

Choose a reason for hiding this comment

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

use postbuild instead of build

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

package.json Outdated
@@ -46,6 +46,7 @@
"stripe": "^17.4.0",
"swr": "^2.2.5",
"uuid": "^11.0.3",
"next-sitemap": "^4.2.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

insert it under next-auth as package.json is alphabetical order.

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add next-sitemap.config.js because it is required.

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

@@ -0,0 +1,5 @@
module.exports = {
siteUrl: 'https://www.yourwebsite.com',
Copy link
Contributor

Choose a reason for hiding this comment

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

Use NEXT_PUBLIC_SITE_URL from @/config

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

Copy link
Contributor

Choose a reason for hiding this comment

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

No you forgot to do this

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Use NEXT_PUBLIC_SITE_URL from @/config

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

@@ -0,0 +1,5 @@
module.exports = {
siteUrl: 'https://www.yourwebsite.com',
generateRobotsTxt: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it false

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Make it false

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add this url https://www.npmjs.com/package/next-sitemap for future ref

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

@@ -0,0 +1,5 @@
module.exports = {
siteUrl: 'https://www.yourwebsite.com',
Copy link
Contributor

Choose a reason for hiding this comment

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

No you forgot to do this

@@ -0,0 +1,5 @@
module.exports = {
siteUrl: 'https://www.yourwebsite.com',
Copy link
Contributor

Choose a reason for hiding this comment

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

Use NEXT_PUBLIC_SITE_URL from @/config

// https://www.npmjs.com/package/next-sitemap
const { NEXT_PUBLIC_SITE_URL } = require('@/config');
module.exports = {
siteUrl: NEXT_PUBLIC_SITE_URL,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, use NEXT_PUBLIC_SITE_URL from env simply not from @/config

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

@@ -0,0 +1,7 @@
// https://www.npmjs.com/package/next-sitemap
const NEXT_PUBLIC_SITE_URL = process.env.NEXT_PUBLIC_SITE_URL;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove it

Copy link
Author

@gitauto-for-dev gitauto-for-dev bot Jan 3, 2025

Choose a reason for hiding this comment

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

Resolved your feedback! Looks good?

@@ -0,0 +1,5 @@
module.exports = {
siteUrl: 'https://www.yourwebsite.com',
generateRobotsTxt: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it false

Copy link

github-actions bot commented Jan 3, 2025

gitauto.ai%2F

Before (main) After (this branch)

Copy link

github-actions bot commented Jan 3, 2025

gitauto.ai%2Fblog

Before (main) After (this branch)

Copy link

github-actions bot commented Jan 3, 2025

gitauto.ai%2Fsettings%2Fintegrations%2Fjira

Before (main) After (this branch)

@hiroshinishio hiroshinishio merged commit 3e7ab45 into main Jan 5, 2025
3 checks passed
@hiroshinishio hiroshinishio deleted the gitauto-wes/issue-167-20250103-221343 branch January 5, 2025 10:10
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.

Make our sitemap dynamically updated using a library
1 participant