# New Page Checklist

Ensure a newly created (or just-added) webpage meets all technical, SEO, and AI-discoverability requirements.

## Arguments

`$ARGUMENTS` should be the full URL of the new page (e.g. `https://www.example.com/new-page`).

If no URL is provided, ask the user for one before proceeding.

## Steps

Work through each item below in order. Check it off as you go. Do not skip any step — if something cannot be applied (e.g. no sitemap file exists), explain why and move on.

---

### 1. Detect project type

Look at the project files to determine if this is:
- **Next.js** — has `next.config.mjs` or `next.config.js` and an `app/` or `pages/` directory
- **Static HTML** — standalone `.html` file(s) with no framework

This affects how you handle the sitemap, schema, and canonical steps below.

---

### 2. Canonical URL

**Next.js page (`.tsx` / `.ts`):**
Ensure the page's `export const metadata` includes:
```ts
alternates: {
  canonical: "<full-page-url>",
}
```

**Static HTML page:**
Ensure the `<head>` contains:
```html
<link rel="canonical" href="<full-page-url>">
```

---

### 3. Meta title & description

**Next.js:** Ensure `export const metadata` has a `title` and `description` field.

**Static HTML:** Ensure the `<head>` has:
```html
<meta name="description" content="...">
<title>...</title>
```

If either is missing or uses a placeholder, write appropriate values based on the page content.

---

### 4. H1 title

Every page must have exactly one `<h1>` tag with a descriptive title that clearly communicates the page's topic.

**Next.js:** Check the page's JSX for a single `<h1>` element. The text must be specific and descriptive — not a generic label like "Home" or "Page".

**Static HTML:** Check the `<body>` for a single `<h1>` tag. Avoid multiple `<h1>` tags on the same page.

If the H1 is missing, add one. If it is vague or generic, rewrite it to accurately describe the page content.

---

### 5. JSON-LD schema markup

Choose the most appropriate schema type for the page:
- Homepage / personal site → `Person`
- About page → `AboutPage`
- Article / blog post → `Article`
- Data report / study → `Dataset` or `Article`
- Tool / product → `SoftwareApplication`
- Course → `Course`
- FAQ → `FAQPage`

**Next.js:** Add a `<script type="application/ld+json">` block inside the page's JSX return, using `dangerouslySetInnerHTML`.

**Static HTML:** Add a `<script type="application/ld+json">` block in the `<head>`.

Include at minimum: `@context`, `@type`, `name`, `url`, and `description`. Add relevant fields for the schema type (e.g. `author`, `datePublished` for articles).

---

### 6. Add page to sitemap

**Next.js:** Open `app/sitemap.ts` and add an entry:
```ts
{
  url: "<full-page-url>",
  lastModified: new Date("<YYYY-MM-DD>"),
  changeFrequency: "monthly", // adjust as appropriate
  priority: 0.7,              // adjust: 1.0 = homepage, 0.8 = key pages, 0.7 = content, 0.5 = utility
}
```

**Static HTML:** If a `sitemap.xml` exists in the project, add a `<url>` entry. If no sitemap exists, note this to the user and suggest creating one.

---

### 7. Update llm.txt

If a `public/llm.txt` (Next.js) or `llm.txt` (static) exists in the project, add a reference to the new page under the appropriate section. If the file does not exist, skip this step and note it.

---

### 8. Embed markdown version in the page

Add a hidden `<script type="text/markdown" id="page-content-md">` block containing a clean markdown summary of the page. Place it just before the closing `</body>` tag (static HTML) or before the closing `</div>` of the root element (Next.js, using `dangerouslySetInnerHTML`).

The markdown should include:
- Page title as an `# H1`
- 1–2 sentence description of the page purpose
- Key sections as `## H2` headings with brief content summaries
- Any important links on the page

---

### 9. Vercel Analytics tracking

**Next.js:** Check if `app/layout.tsx` already includes `<Analytics />` from `@vercel/analytics/next`. If it does, the page is covered automatically — mark as done. If not, add it to the layout (preferred) or to the page directly:
```tsx
import { Analytics } from "@vercel/analytics/next"
// inside the JSX:
<Analytics />
```

**Static HTML:** Ensure the `<head>` contains:
```html
<script defer src="/_vercel/insights/script.js"></script>
```
If it is missing, add it as the last item before `</head>`.

---

### 10. Mobile responsiveness check

Read the page's CSS or Tailwind classes and check for common mobile issues:

- Do multi-column grid layouts collapse to single column on small screens? (`@media (max-width: 768px)` or responsive Tailwind prefixes like `md:`)
- Are there any `width` or `height` values hardcoded in pixels that could overflow on mobile?
- For Chart.js charts: are canvases wrapped in a sized container with `maintainAspectRatio: false`?
- Is the page padding/margin appropriate on small screens?

Report any issues found. Fix them if they are straightforward; flag them for the user if complex.

---

### 11. Run and test locally

Start the dev server if it is not already running:

**Next.js:**
```bash
npm run dev
```
Server starts at `http://localhost:3000`. Derive the local URL from the page's path (e.g. `https://www.example.com/about` → `http://localhost:3000/about`).

**Static HTML:**
```bash
npx serve public
```
Or open the file directly in the browser if no server is needed.

Then verify the following by fetching or opening the page:
- Page loads without errors (check terminal output for build errors)
- Canonical URL is present in the rendered HTML (`curl http://localhost:3000/page | grep canonical`)
- JSON-LD schema block is present (`curl ... | grep "application/ld+json"`)
- Vercel Analytics script / component is present
- Markdown embed block is present (`curl ... | grep "text/markdown"`)
- Page renders correctly on mobile — use browser DevTools device toolbar (375px width) and check for obvious layout breakage

Report what was confirmed and flag anything that looked wrong.

---

### 12. Summary report

After completing all steps, output a short checklist showing what was done, what was already in place, and anything skipped or flagged:

```
✅ Canonical URL — set
✅ Meta title & description — set
✅ H1 title — present and descriptive
✅ JSON-LD schema — added (Article)
✅ Sitemap — added
✅ llm.txt — updated
✅ Markdown embed — added
✅ Vercel Analytics — present
⚠️  Mobile check — found: [describe issue or "no issues"]
✅ Local test — page loads, all tags confirmed present
```

## Rules

- Never modify files outside the page itself, its sitemap entry, and llm.txt.
- Never push to git — leave that to the user.
- If a step is already correctly implemented, mark it done and move on without making unnecessary changes.
- Keep schema markup accurate — do not invent facts about the page.
