Skip to content

Commit 942c7f7

Browse files
updates
1 parent 9e56fcf commit 942c7f7

5 files changed

Lines changed: 174 additions & 1 deletion

File tree

.github/workflows/deploy-github-pages.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
- run: npm ci
3636
- run: npm run build
3737

38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: sitemap
41+
path: out/sitemap.xml
42+
3843
- uses: actions/upload-pages-artifact@v3
3944
with:
4045
path: out
@@ -50,3 +55,21 @@ jobs:
5055
steps:
5156
- id: deploy
5257
uses: actions/deploy-pages@v4
58+
59+
indexnow:
60+
runs-on: ubuntu-latest
61+
needs: deploy
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- uses: actions/setup-node@v4
67+
with:
68+
node-version: '22'
69+
70+
- uses: actions/download-artifact@v4
71+
with:
72+
name: sitemap
73+
path: out
74+
75+
- run: npm run indexnow

IndexNowImplmentation.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
You are working on my existing Next.js website for proxytechsupport.com.
2+
3+
Task:
4+
Implement IndexNow support as a pure addition only.
5+
6+
Very important rules:
7+
- Do NOT refactor existing SEO code.
8+
- Do NOT change existing sitemap logic unless absolutely required.
9+
- Do NOT change robots.txt unless only adding a missing sitemap line.
10+
- Do NOT change existing metadata, canonical URLs, redirects, schema, blog routes, service pages, or static export behavior.
11+
- Do NOT break GitHub Pages / Cloudflare deployment.
12+
- This must be additive and safe.
13+
14+
My IndexNow key is:
15+
49dca91567b14de2bde9ba54739351bd
16+
17+
Required implementation:
18+
19+
1. Add the IndexNow key file in the public root:
20+
public/49dca91567b14de2bde9ba54739351bd.txt
21+
22+
The file content must be exactly:
23+
49dca91567b14de2bde9ba54739351bd
24+
25+
After deployment, this URL must work:
26+
https://proxytechsupport.com/49dca91567b14de2bde9ba54739351bd.txt
27+
28+
2. Create a safe IndexNow helper file, for example:
29+
scripts/submit-indexnow.mjs
30+
31+
It should:
32+
- Use Node.js only.
33+
- Not require new packages unless already available.
34+
- Read URLs from the existing sitemap if possible.
35+
- Submit URLs to:
36+
https://api.indexnow.org/indexnow
37+
- Use POST JSON body:
38+
{
39+
"host": "proxytechsupport.com",
40+
"key": "49dca91567b14de2bde9ba54739351bd",
41+
"keyLocation": "https://proxytechsupport.com/49dca91567b14de2bde9ba54739351bd.txt",
42+
"urlList": [...]
43+
}
44+
45+
3. The script must be defensive:
46+
- If sitemap is missing, do not fail the build.
47+
- If IndexNow API fails, log warning only.
48+
- Never block production deployment.
49+
- Limit URL submissions if needed to avoid huge payload.
50+
- Only submit canonical https://proxytechsupport.com URLs.
51+
- Do not submit localhost, staging, duplicate URLs, or invalid URLs.
52+
53+
4. Add package.json script only if safe:
54+
"indexnow": "node scripts/submit-indexnow.mjs"
55+
56+
Do not modify existing build/start/export scripts unless needed.
57+
Do not run IndexNow automatically inside build unless I explicitly ask later.
58+
59+
5. Add a short comment in the script explaining:
60+
IndexNow helps faster discovery of new/updated URLs but does not guarantee ranking.
61+
62+
6. After implementation, show me:
63+
- Files created
64+
- Exact code added
65+
- How to run manually
66+
- How to verify key file URL
67+
- Confirmation that no existing SEO behavior was changed
68+
69+
Before editing, inspect the project structure first.
70+
Then implement only the minimum safe addition.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "node scripts/verify-content-urls.mjs && next build",
99
"export": "node scripts/verify-content-urls.mjs && next build",
1010
"start": "next start",
11-
"lint": "eslint"
11+
"lint": "eslint",
12+
"indexnow": "node scripts/submit-indexnow.mjs"
1213
},
1314
"dependencies": {
1415
"gray-matter": "^4.0.3",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
49dca91567b14de2bde9ba54739351bd

scripts/submit-indexnow.mjs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// IndexNow helps faster discovery of new/updated URLs but does not guarantee ranking.
2+
// Run manually after deployment: npm run indexnow
3+
// Docs: https://www.indexnow.org/documentation
4+
5+
import { readFileSync, existsSync } from 'node:fs';
6+
import { resolve, join } from 'node:path';
7+
8+
const HOST = 'proxytechsupport.com';
9+
const KEY = '49dca91567b14de2bde9ba54739351bd';
10+
const KEY_LOCATION = `https://${HOST}/${KEY}.txt`;
11+
const API_URL = 'https://api.indexnow.org/indexnow';
12+
const MAX_URLS = 10_000;
13+
14+
function extractUrlsFromSitemap(xml) {
15+
const urls = [];
16+
const locRegex = /<loc>(.*?)<\/loc>/g;
17+
let match;
18+
while ((match = locRegex.exec(xml)) !== null) {
19+
urls.push(match[1].trim());
20+
}
21+
return urls;
22+
}
23+
24+
function isCanonical(url) {
25+
try {
26+
const parsed = new URL(url);
27+
return parsed.protocol === 'https:' && parsed.hostname === HOST;
28+
} catch {
29+
return false;
30+
}
31+
}
32+
33+
async function main() {
34+
const root = resolve(import.meta.dirname, '..');
35+
const sitemapPath = join(root, 'out', 'sitemap.xml');
36+
37+
if (!existsSync(sitemapPath)) {
38+
console.warn('[IndexNow] sitemap.xml not found at', sitemapPath, '— skipping submission.');
39+
return;
40+
}
41+
42+
let xml;
43+
try {
44+
xml = readFileSync(sitemapPath, 'utf8');
45+
} catch (err) {
46+
console.warn('[IndexNow] Failed to read sitemap.xml:', err.message);
47+
return;
48+
}
49+
50+
const allUrls = extractUrlsFromSitemap(xml);
51+
const urlList = [...new Set(allUrls.filter(isCanonical))].slice(0, MAX_URLS);
52+
53+
if (urlList.length === 0) {
54+
console.warn('[IndexNow] No valid canonical URLs found in sitemap — skipping submission.');
55+
return;
56+
}
57+
58+
console.log(`[IndexNow] Submitting ${urlList.length} URLs to IndexNow...`);
59+
60+
const body = JSON.stringify({ host: HOST, key: KEY, keyLocation: KEY_LOCATION, urlList });
61+
62+
try {
63+
const res = await fetch(API_URL, {
64+
method: 'POST',
65+
headers: { 'Content-Type': 'application/json; charset=utf-8' },
66+
body,
67+
});
68+
if (res.ok) {
69+
console.log(`[IndexNow] Success — HTTP ${res.status}`);
70+
} else {
71+
console.warn(`[IndexNow] API returned HTTP ${res.status}: ${await res.text()}`);
72+
}
73+
} catch (err) {
74+
console.warn('[IndexNow] API request failed (network issue?):', err.message);
75+
}
76+
}
77+
78+
main();

0 commit comments

Comments
 (0)