Most content sites have pages that sit at average positions 11 to 20 for queries Google already associates with them. Many of those pages have few or no links from the rest of the site, because nobody went back to add them after publishing.
Google's documentation is specific about what links do, and it gives no number for how much. The link best practices page opens with: "Google uses links as a signal when determining the relevancy of pages and to find new pages to crawl." The same page says anchor text "tells people and Google something about the page you're linking to". The SEO starter guide states that "the vast majority of the new pages Google finds every day are through links". The sitemaps overview says that if "your site's pages are properly linked, Google can usually discover most of your site". None of these pages promises a position change, and this article won't either. Adding descriptive links to pages that lack them is maintenance, with Search Console telling you where to look first.
Search Console reports which page appears for which query and at what position. A script can pull that, a coding tool can read your Markdown files and propose links where the existing text already uses the right phrase, and Git gives you a branch, a diff and a pull request as the review step and the changelog.
1. Get page and query data in the same row
This is where the workflow usually breaks. The Performance report in Search Console shows a Queries table and a Pages table, but the export doesn't tell you which query belongs to which page. The export is also small. Google's export documentation says report data is "truncated to 1,000 rows of representative examples of your data". To say "page X ranks 12th for query Y" you need both dimensions in one row, and the Search Console API returns that.
Four more facts about the data, all from Google:
- Some queries never appear. The Search Central blog post A deep dive into Search Console performance data filtering and limits defines anonymized queries as those "that aren't issued by more than a few dozen users over a two-to-three month period", and they "are always omitted from the tables". On a small site that is a large share of the long tail. The queries you want for this job are the ones with real impressions, so the loss doesn't matter here. The same post caps the API at "50,000 rows per day per site per search type", so a site with more page-and-query pairs than that gets the top rows, not all of them.
- Position means the topmost result. The Performance report documentation defines average position as "the average position of the topmost result from your site" for that row.
- The data lags. The About Search Console data page says collected data "should be available in 2-3 days", so the export below stops three days before today.
- AI Overviews and AI Mode impressions are in these rows. Google's AI features documentation says sites appearing in AI features "are included in the overall search traffic in Search Console" and are reported in the Performance report "within the 'Web' search type", which is the type the script below requests. Since 3 June 2026 there is also a separate Generative AI performance report, rolled out to all sites on 31 August 2026 according to the launch post. It shows impressions only, grouped by pages, countries, devices and dates, with no query dimension, so it tells you which pages appeared in AI Overviews or AI Mode but not for which queries. Find it under Performance in the Search Console sidebar, or open it directly at search.google.com/search-console/performance/search-analytics/ai. If it isn't there, the help page says the site "hasn't received enough impressions in generative AI features".
One-time setup:
- In the Google Cloud console, create a project and enable the Google Search Console API. Then open the Service accounts page and create a service account. Google's key documentation gives the next clicks: open the service account, "Click the Keys tab", then "Click the Add key drop-down menu, then select Create new key", and "Select JSON as the Key type and click Create". The file downloads once.
- In Search Console, open Settings, then Users and permissions, and add the service account's email address as a Full user. The permissions documentation says a Full user "has view rights to all data".
- Keep the key outside the repository, or add it to
.gitignore. Never commit it.
npm i -D googleapis
echo ".gsc/" >> .gitignore
echo "gsc-key.json" >> .gitignore
Then add scripts/gsc-export.mjs:
// scripts/gsc-export.mjs
import { google } from 'googleapis';
import { mkdirSync, writeFileSync } from 'node:fs';
const SITE = process.env.GSC_SITE; // 'sc-domain:example.com' or 'https://example.com/'
const day = (n) => new Date(Date.now() - n * 864e5).toISOString().slice(0, 10);
const auth = new google.auth.GoogleAuth({
keyFile: process.env.GSC_KEY_FILE,
scopes: ['https://www.googleapis.com/auth/webmasters.readonly'],
});
const gsc = google.searchconsole({ version: 'v1', auth });
const rows = [];
for (let startRow = 0; ; startRow += 25000) {
const { data } = await gsc.searchanalytics.query({
siteUrl: SITE,
requestBody: {
startDate: day(93),
endDate: day(3), // the most recent days are still filling in
dimensions: ['page', 'query'],
type: 'web',
rowLimit: 25000,
startRow,
},
});
rows.push(...(data.rows ?? []));
if (!data.rows || data.rows.length < 25000) break;
}
mkdirSync('.gsc', { recursive: true });
writeFileSync('.gsc/page-query.json', JSON.stringify(rows.map((r) => ({
page: r.keys[0],
query: r.keys[1],
clicks: r.clicks,
impressions: r.impressions,
position: Math.round(r.position * 10) / 10,
})), null, 2));
console.log(`Saved ${rows.length} rows`);
Run it:
GSC_SITE="sc-domain:example.com" GSC_KEY_FILE="$HOME/keys/gsc-key.json" node scripts/gsc-export.mjs
Expected output, with your own row count:
Saved 1842 rows
The Search Analytics query reference says the valid range for rowLimit is 1 to 25,000 and the default is 1,000, so the loop pages with startRow. It also defines type: 'web' as the "combined ("All") tab in Google Search", which excludes Discover and Google News. The webmasters.readonly scope is one of the two scopes on the API's authorization page, listed there as "Read-only access", and it is all this script needs. Two quota notes from the API's usage limits page: the per-site limit is 1,200 queries per minute, which a daily export never approaches, and queries "grouped/filtered by page AND query string are the most expensive" for the load quota, so don't run this in a loop over many date ranges at once. The googleapis package was at version 189.0.0 on npm on 12 November 2026.
If your coding tool already has a Search Console connector, you can skip the script. A JSON file in the repository is easier to rerun and diff, though.
2. Put numbers on "page 2" and "enough impressions"
Vague instructions get interpreted however the model likes. Give it numbers.
- Position: target pairs where the page's average position is between 11 and 20. Those are the results on the second page of classic ten-result pages, and Search Console reports them even though searchers rarely see them. A wider band, 4 to 20, is defensible when the site is small and you want more rows.
- Impressions: for a small local business site over three months, 50 impressions for the page-and-query pair is a workable floor. A blog with real traffic might use 200. Pick the number that leaves you with 20 to 60 pairs you can actually review.
- One rule, not two. A common version of this workflow says to take queries ranking 1 to 10 as anchor sources, then prioritize targets ranking 4 to 15. Those two rules fight each other: a page sitting at 13 has no top-10 query, so it never becomes a target. Use the single position band above.
3. Work on a branch
git switch -c internal-links-$(date +%F)
Then give your coding tool the prompt at the end of this article. Tell it where content lives and how URLs map to files. For Astro, the content collections guide defines collections in src/content.config.ts, and its example loads ./src/content/blog with a glob pattern of **/*.{md,mdx}. Search Console reports full URLs like https://example.com/blog/tankless-vs-tank/, and the tool has to turn that into src/content/blog/tankless-vs-tank.md. Astro's configuration reference lists trailingSlash as 'always', 'never' or 'ignore', default 'ignore'. If your config sets it, new links must match it, or every new link costs a redirect hop.
4. Review the plan before any edit
The tool writes the plan to .gsc/link-plan.md and stops. Go through every row. Reject a row if:
- the anchor doesn't make sense read on its own
- the source page has nothing to do with the target
- it's a self-link, or the target is already linked from that page
- the same exact anchor shows up on more than two or three source pages
Google's link best practices page covers each of those. "Good anchor text is descriptive, reasonably concise, and relevant to the page that it's on and to the page it links to." The test Google suggests: "Try reading only the anchor text (out of context) and check if it's specific enough to make sense by itself." On repetition: "resist the urge to cram every keyword" into anchors, because "keyword stuffing is a violation of our spam policies". And on placement: "Don't chain up links next to each other". Twenty posts all linking one page with the identical exact-match query reads as engineered, because it is. Use partial matches, the page's topic in your own words, or the query with a city name added.
For scale, the 2025 Web Almanac SEO chapter measured a median of 43 same-site links per desktop page and 39 per mobile page, and found that 93.45% of mobile inner pages pass Lighthouse's descriptive-link-text audit. Three contextual links added to a body paragraph are a small change on a normal page, not a restructuring.
5. Apply the edits as a pull request
After you approve rows, the tool edits the Markdown and commits. Then build, check links, and open the PR:
npm run build
npx linkinator ./dist --recurse --skip "^https?://(?!localhost|127\.0\.0\.1)"
gh pr create --title "Internal links from Search Console, $(date +%F)" --body-file .gsc/link-plan.md
The build catches broken MDX. Linkinator (version 8.1.0 on npm on 12 November 2026) will, in its README's words, "stand up a static web server" for the dist folder, follow links on the same root with --recurse, and exit with code 1 when it detects a broken link. The --skip flag takes "urls in regexy form to not include in the check". The pattern above matters: the local server runs on 127.0.0.1, so a pattern that skips every http URL also skips the server itself and the run reports zero links scanned. Excluding localhost and 127.0.0.1 from the skip tests your own links and ignores every external host. Tested on 12 November 2026 against a four-link test build: one missing page gave "ERROR: Detected 1 broken links" and exit code 1. Write the new links root-relative, as the prompt says, so they are checked against the build and not against your live site. The PR body is the approved table, and the diff shows every changed sentence. Reverting a bad batch is one git revert. The gh pr create manual documents --title and --body-file.
Read the diff anyway. Look for rewritten sentences (the tool was told not to, and sometimes does), links inside headings or front matter, and links dropped into code blocks.
6. Measure with matching date ranges, and say less than you'd like
Write down the merge date. New links only count once Google recrawls the source pages, the ones you edited, not the targets. For a handful of important source pages you can use URL Inspection and Request indexing. Google's recrawl documentation warns that "requesting a recrawl multiple times for the same URL won't get it crawled any faster", and that "Crawling can take anywhere from a few days to a few weeks."
Wait at least four weeks. Then compare two windows of equal length: the 28 days before the merge, and the 28 days starting a week after it. The Performance report does this in the date filter. Google's advanced filtering and comparison page says to "Choose Compare in the filter properties dialog box", after which "the results table will display a Difference column", and it recommends weekly or monthly granularity for date comparisons because it "neutralizes the 'day-of-the-week' effect". Or run the export script twice with those date ranges and diff the two files for the target pairs only. Look at impressions and average position per page-and-query pair, not site totals.
Then be careful about what the comparison proves. Average position moves week to week on its own. Seasonality, a core update, a competitor's new page or a new backlink can all land in the same window. Google's documentation calls links a relevancy signal and a discovery mechanism without saying how much either weighs, so an improvement after this work is consistent with the documentation but not proof of cause. What you can state with certainty is narrower and still useful: the target pages now have crawlable, descriptive links from related pages, which is what Google's guidance asks for, and the PR records exactly what changed and when.
This is also why running the workflow weekly on overlapping pages makes results unreadable. Do one batch, wait, compare, then do the next batch on different targets.
Illustrative example
Illustrative example: a home services blog has 40 posts in Astro content collections. The export returns 1,842 page-and-query rows for 90 days. Filtering to positions 11 to 20 with at least 50 impressions leaves 14 target pairs. One is /blog/tankless-vs-tank/ at position 13.4 for "tankless water heater cost", 310 impressions and 4 clicks. The link plan finds three body sentences on other posts that already contain "tankless water heater" or "cost of a tankless unit", so three links go in with those existing words as anchors, no sentence rewritten. The plan also lists five targets with no natural spot, and those stay unlinked rather than forced. Merge date and the 14 pairs go in the PR body. The comparison happens five weeks later, pair by pair.
The prompt
Paste this into your coding tool and fill in the brackets:
You are working in a Git repo for [site name], built with [Astro / Eleventy / Hugo].
Content files: [src/content/blog/**/*.md and *.mdx]. URLs map to files like this: [https://example.com/blog/<slug>/ -> src/content/blog/<slug>.md]. Trailing slash setting: [always / never].
Search Console data (page, query, clicks, impressions, position, last 3 months): .gsc/page-query.json
Step 1, pick targets. A target is a page + query pair with position between 11 and 20 and at least [50] impressions. Ignore URLs you can't map to a file.
Step 2, find link spots. For each target, search the other content files for places where the existing text already says the query, a close variant or the same idea in other words. Only use sentences in body paragraphs. Never use headings, front matter, the first paragraph, image alt text, code blocks, MDX components or text that is already a link.
Rules:
- At most [3] new links per source file, and each target linked once per source file.
- No self-links. Skip a source file that already links to the target.
- The source page must be on a related topic. If it isn't, don't link.
- Do not rewrite or add sentences to fit an anchor. Wrap existing words only.
- Vary anchors. Don't use the identical exact-match anchor for the same target on more than [2] source files. Use partial matches and descriptive wording instead.
- Links are root-relative Markdown links, e.g. [anchor](/blog/slug/), matching the trailing slash setting.
- Prefer targets with the most impressions first.
Step 3, plan only. Write .gsc/link-plan.md as a table: source file | sentence (with the anchor in brackets) | target URL | target query | position | impressions. Below it, list targets you found no natural spot for. Do not edit any content file yet. Stop and wait for my approval.
Step 4, after I reply "approved" (or approve specific rows), apply only the approved rows, commit with the message "Add internal links from Search Console data", and show me git diff --stat.
Check the output by picking five rows from the plan and opening the source file yourself. The bracketed words should already be in the sentence, unchanged, and the sentence should still make sense if you read only the anchor.
Where to start
Run the export, filter to positions 11 to 20 with your impression floor, and do one batch of ten targets. Merge it, write the date in the PR, and leave those pages alone until the before-and-after comparison is done.
This article was written with AI assistance and checked by a person.
If that's too much work, contact us and we'll make you a free website.
Top comments (0)