Skip to content

feat: automation of new urls added in sitemap using new slugs on wordpress - 🚧#346

Closed
amaan-bhati wants to merge 3 commits intomainfrom
sitemap-automation
Closed

feat: automation of new urls added in sitemap using new slugs on wordpress - 🚧#346
amaan-bhati wants to merge 3 commits intomainfrom
sitemap-automation

Conversation

@amaan-bhati
Copy link
Copy Markdown
Member

Related Tickets & Documents

Fixes: #[issue-number]

Description

Changes

Type of Change

  • Chore (maintenance, refactoring, tooling updates)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (change that adds functionality)
  • Breaking Change (may require updates in existing code)
  • UI improvement (visual or design changes)
  • Performance improvement (optimization or efficiency enhancements)
  • Documentation update (changes to README, guides, etc.)
  • CI (updates to continuous integration workflows)
  • Revert (undo a previous commit or merge)

Testing

Demo

Environment and Dependencies

  • New Dependencies:
  • Configuration Changes:

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added corresponding tests
  • I have run the build command to ensure there are no build errors
  • My changes have been tested across relevant browsers/devices
  • For UI changes, I've included visual evidence of my changes

Signed-off-by: amaan-bhati <amaanbhati49@gmail.com>
…press

Signed-off-by: amaan-bhati <amaanbhati49@gmail.com>
Copilot AI review requested due to automatic review settings March 12, 2026 01:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces automation to keep public/sitemap.xml updated with new WordPress blog post URLs (technology/community) by adding sync scripts and a scheduled GitHub Actions workflow that opens an automated PR when changes are detected.

Changes:

  • Added Node scripts to fetch post slugs from WPGraphQL and append missing /blog/technology/* and /blog/community/* entries into public/sitemap.xml.
  • Added npm scripts to run the sitemap sync from CI.
  • Added a scheduled GitHub Actions workflow to run the sync periodically and create a PR with sitemap updates.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/sync-tech-urls-to-sitemap.mjs Adds a script to fetch technology posts from WPGraphQL and append missing sitemap <url> entries.
scripts/sync-blog-urls-to-sitemap.mjs Adds a script to fetch all posts, map them to community/technology URLs, and append missing sitemap entries.
public/sitemap.xml Updates the sitemap content with many new/changed entries.
package.json Adds npm scripts to run the sitemap sync scripts.
.github/workflows/sitemap_sync.yml Adds a scheduled workflow to run the sync and open an automated PR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread public/sitemap.xml
Comment on lines +1 to 2
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

public/sitemap.xml is not valid XML: the first line is a plain-text message (likely copied from a browser view) and the XML prolog (<?xml version="1.0" encoding="UTF-8"?>) is missing. This will break sitemap consumers and will also fail the workflow xmllint validation; remove the plain-text line and restore the XML declaration at the top of the file.

Copilot uses AI. Check for mistakes.
Comment thread public/sitemap.xml
Comment on lines +4 to +16
<url>
<loc>https://keploy.io/blog</loc>
<lastmod>2026-03-11T21:50:59+00:00</lastmod>
<priority>1.00</priority>
</url>
<url>
<loc>https://keploy.io/blog/technology</loc>
<lastmod>2026-03-11T21:50:59+00:00</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://keploy.io/blog/community</loc>
<lastmod>2026-03-11T21:50:59+00:00</lastmod>
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Many <lastmod> values appear to have been rewritten to the same sync timestamp (e.g. the /blog, /blog/technology, /blog/community entries). lastmod is intended to reflect the actual last modification time of each URL; setting it to a bulk-generated timestamp can mislead crawlers and trigger unnecessary recrawls. Prefer keeping existing lastmod values unchanged and only setting lastmod for newly added URLs based on WordPress modified/date.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +93
const loc = normalizeUrl(`https://keploy.io/blog/technology/${node.slug}`);
const lastmod = toIso(node.modified) || toIso(node.date) || "2026-03-11T21:50:59+00:00";
return {
loc,
xml: `<url>\n<loc>${loc}</loc>\n<lastmod>${lastmod}</lastmod>\n<priority>0.51</priority>\n</url>\n`,
};
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

lastmod falls back to a hard-coded timestamp. If modified/date is missing or unparsable, this will silently write a stale value and is easy to forget to update later. Prefer using the current time (or omitting <lastmod> when unknown) instead of a fixed constant.

Copilot uses AI. Check for mistakes.
Comment on lines +110 to +118
const url = buildBlogUrl(node);
if (!url) return null;
const loc = normalizeUrl(url);
const lastmod = toIso(node.modified) || toIso(node.date) || "2026-03-11T21:50:59+00:00";
return {
loc,
lastmod,
xml: `<url>\n<loc>${loc}</loc>\n<lastmod>${lastmod}</lastmod>\n<priority>0.51</priority>\n</url>\n`,
};
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

lastmod falls back to a hard-coded timestamp. If modified/date is missing or unparsable, this will write an arbitrary (and eventually stale) value into the sitemap. Prefer using the current time (or omitting <lastmod> when unknown) rather than a fixed constant.

Copilot uses AI. Check for mistakes.
});

if (!response.ok) {
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message lacks actionable next step.

The error message indicates the API request failed but doesn't guide the user on what to do next. Consider adding suggestions like checking network connectivity, verifying the WordPress GraphQL endpoint is accessible, or checking if the API URL has changed.

Suggested change
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}`);
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}. Check that ${apiUrl} is accessible and the WordPress site is running.`);

async function main() {
const sitemapXml = await fs.readFile(SITEMAP_PATH, "utf8");
if (!sitemapXml.includes("</urlset>")) {
throw new Error("Invalid sitemap.xml: missing </urlset>");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message lacks actionable next step.

This error indicates the sitemap is invalid but doesn't tell the user how to fix it. Consider adding guidance on what a valid sitemap should contain.

Suggested change
throw new Error("Invalid sitemap.xml: missing </urlset>");
throw new Error("Invalid sitemap.xml: missing </urlset>. Ensure the file contains valid XML with a proper <urlset> root element and closing tag.");

}

main().catch((err) => {
console.error(err.message || err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message should include actionable next step.

When an error occurs, the user should know what to do next. Consider adding guidance based on common failure scenarios.

Suggested change
console.error(err.message || err);
console.error(`Error: ${err.message || err}. Check the WordPress API availability, network connectivity, and ensure public/sitemap.xml exists and is valid XML.`);

});

if (!response.ok) {
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message lacks actionable next step.

The error message indicates the API request failed but doesn't guide the user on what to do next.

Suggested change
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}`);
throw new Error(`WPGraphQL request failed: ${response.status} ${response.statusText}. Check that ${apiUrl} is accessible and the WordPress site is running.`);

async function main() {
const sitemapXml = await fs.readFile(SITEMAP_PATH, "utf8");
if (!sitemapXml.includes("</urlset>")) {
throw new Error("Invalid sitemap.xml: missing </urlset>");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message lacks actionable next step.

This error indicates the sitemap is invalid but doesn't tell the user how to fix it.

Suggested change
throw new Error("Invalid sitemap.xml: missing </urlset>");
throw new Error("Invalid sitemap.xml: missing </urlset>. Ensure the file contains valid XML with a proper <urlset> root element and closing tag.");

}

main().catch((err) => {
console.error(err.message || err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Error message should include actionable next step.

When an error occurs, the user should know what to do next.

Suggested change
console.error(err.message || err);
console.error(`Error: ${err.message || err}. Check the WordPress API availability, network connectivity, and ensure public/sitemap.xml exists and is valid XML.`);

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented Mar 24, 2026

Code Review Summary

Status: 10 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 2
WARNING 2
SUGGESTION 6
Issue Details (click to expand)

CRITICAL

File Line Issue
public/sitemap.xml 2 Invalid XML: first line is plain-text browser message, missing XML prolog (<?xml version="1.0" encoding="UTF-8"?>). Will fail xmllint validation in workflow.
public/sitemap.xml 16 Many <lastmod> values rewritten to same timestamp (bulk-sync timestamp), misleading crawlers and triggering unnecessary recrawls.

WARNING

File Line Issue
scripts/sync-tech-urls-to-sitemap.mjs 89 lastmod falls back to hard-coded timestamp 2026-03-11T21:50:59+00:00. Will become stale and misleading over time.
scripts/sync-blog-urls-to-sitemap.mjs 113 lastmod falls back to hard-coded timestamp 2026-03-11T21:50:59+00:00. Will become stale and misleading over time.

SUGGESTION

File Line Issue
scripts/sync-blog-urls-to-sitemap.mjs 71 Error message lacks actionable next step for user.
scripts/sync-blog-urls-to-sitemap.mjs 126 Error message lacks actionable next step for user.
scripts/sync-blog-urls-to-sitemap.mjs 165 Error message lacks actionable next step for user.
scripts/sync-tech-urls-to-sitemap.mjs 43 Error message lacks actionable next step for user.
scripts/sync-tech-urls-to-sitemap.mjs 100 Error message lacks actionable next step for user.
scripts/sync-tech-urls-to-sitemap.mjs 131 Error message lacks actionable next step for user.
Files Reviewed (5 files)
  • .github/workflows/sitemap_sync.yml - 0 new issues (workflow structure looks good)
  • package.json - 0 issues
  • public/sitemap.xml - 2 issues (CRITICAL)
  • scripts/sync-blog-urls-to-sitemap.mjs - 4 issues (1 WARNING, 3 SUGGESTION)
  • scripts/sync-tech-urls-to-sitemap.mjs - 4 issues (1 WARNING, 3 SUGGESTION)

Fix these issues in Kilo Cloud


Reviewed by claude-4.5-opus-20251124 · 664,830 tokens

@amaan-bhati
Copy link
Copy Markdown
Member Author

clsoing this pr since we found a cheaper and more optimised + faster approach in this pr: #374

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.

3 participants