Repository navigation
feat(content): keep an inventory of each brand's site pages - #936
Merged
Merged
Conversation
Content opportunities can only say "update the page you have" instead of "write a new one" if they know which pages the site has (#857, Phase 2). - Migration 00104 adds site_pages: up to 500 pages per brand with their sources, GA sessions and AI citations over 30 days, title, meta description, first heading and last read status. Page bodies are not stored. It also adds brand_landing_page_sessions for the GA side. - lib/site-pages.js picks the pages from the sitemap (robots.txt Sitemap lines, else /sitemap.xml, one level of index, gzip supported), GA landing pages and the brand's own cited URLs, pages with citations and traffic first. The site is not crawled. - Each page's head is read directly and re-read every 30 days. Only a page that answers with a bot wall goes through Scrape.do, unrendered. The run logs how many pages went each way. - The tracking worker refreshes the inventory between the cluster refresh and opportunity generation. A failed refresh does not block generation.
7 tasks done
gkhngyk
added a commit
that referenced
this pull request
Oct 5, 2026
#939) Opportunities suggested new content even when the site already had a page for the need (#857, Phase 2). Generation now reads the site page inventory (#936) and says what to do with which page. - lib/page-matching.js narrows a brand's pages to the 8 most likely to cover a cluster's need, by the rarer words they share. No model call. - The generation call sees those pages, with their AI citations, sessions and last-modified date, and returns a decision per cluster: create, optimize, expand, refresh, consolidate or defend, with the pages it is about. Every decision but create needs a page and consolidate needs two; one that lacks them falls back. - Consolidate is only for near-duplicate pages about the same need, and an opportunity takes at most 3 clusters from other topics before it stops being offered as a merge target. Both came from bad results on real data. - Migration 00105 adds content_opportunities.decision. The pages are kept in source_data.targetPages and survive merges. - The brief works on the named page instead of drafting a new one. - The list shows the decision under the type, and the detail page has a "Your Site" card with the decision and links to the pages.
This was referenced Oct 7, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First PR of Phase 2 in #857. Content opportunities suggest new content even when the site already has a page for the need. On the main test brand, an opportunity proposed a "software list for AI SEO and AEO" while the site already has a complete list of AI SEO tools that AI answers cite. This PR keeps an inventory of each brand's pages. The next PR uses it to decide between creating, optimizing, expanding or refreshing.
What is collected
site_pages(migration 00104).Where pages come from
The site is not crawled. Pages come from lists the brand already publishes or that we already hold:
Sitemap:lines in robots.txt, otherwise/sitemap.xmland/sitemap_index.xml. One level of sitemap index is followed and gzipped sitemaps are read. At most 5,000 URLs.brand_landing_page_sessions.ae_owned_citations.Which pages are kept
www., no query or fragment, no trailing slash.page-paths.jsare dropped. Subdomains count as the site.How pages are read
AnsvisorBotuser agent and a 10 s timeout, five at a time.render: false: a 401, 403, 429 or 503, or a challenge page.When it runs
Tried on production data
The migration is applied. The main test brand produced:
The 404s are real. They are deleted pages that still received 268 GA sessions in 30 days. The next PR will not treat them as existing pages.
Related issue
Part of #857 (Phase 2)
Type of change
feat— New featuretest— Adding or updating testsHow to test
refreshSitePages('<brand id>')fromserver/src/lib/site-pages.jsfor a brand with a primary domain.site_pages: titles and descriptions are filled, andsourcesshows sitemap, ga and citation.read: 0, because nothing is re-read within 30 days.site-pages.test.jscovers URL normalization, sitemap and robots.txt parsing, head parsing, bot-wall detection and page selection.Checklist
yarn lint,yarn format:checkandyarn test(969) pass (run fromserver/)supabase/schema.sqlrebuilt withbuild-schema.sh🤖 Generated with Claude Code