# Website Sitemap, SEO & Broken Link Health Auditor (`wearable_drift/site-health-audit`) Actor

Crawls a public site via robots.txt/sitemaps (.xml & .xml.gz) and internal links, audits SEO tags, H1s, canonicals, noindex, alt text, OG/Twitter, JSON-LD, mixed content, security headers, and broken links, and outputs a 0-100 health score plus an HTML report.

- **URL**: https://apify.com/wearable_drift/site-health-audit.md
- **Developed by:** [Maksym Paraska](https://apify.com/wearable_drift) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Website Sitemap, SEO & Broken Link Health Auditor

Lightweight Apify Actor that audits a public website for technical, link, and on-page SEO health without a headless browser or paid proxies.

Give it a `startUrl`. It reads `robots.txt` and XML sitemaps (including sitemap indexes and `.xml.gz` gzipped sitemaps), follows same-origin internal HTML links up to `maxPages` with configurable concurrency and a polite delay, checks broken internal (and optionally external) links, calculates a **0–100 health score**, and generates both a structured dataset and a standalone **HTML audit report** (`OUTPUT_REPORT`).

### Features

- **Multi-page discovery & crawling:** Reads `robots.txt` `Sitemap:` directives, `/sitemap.xml`, `/sitemap_index.xml`, nested sitemap indexes, and `.xml.gz` sitemaps, plus follows same-origin internal HTML links (skipping static binary assets in the HTML queue while still verifying them for broken links).
- **Per-page SEO checks:** Missing or duplicate `<title>` and meta descriptions across crawled pages, title/meta length checks, missing or multiple `<h1>` headings, missing/invalid/mismatched `<link rel="canonical">`, `noindex`/`nofollow` (`meta robots`, `meta googlebot`, and `X-Robots-Tag`), missing `<html lang>`, missing `<meta name="viewport">`, images missing `alt` attributes, Open Graph & Twitter/X card tags, JSON-LD structured data parsing, `hreflang` alternates, and HTTPS mixed-content URLs.
- **Technical & hygiene checks:** Response time (`ms`), payload size (bytes), redirect chains and redirect-loop detection, 4xx/5xx errors, `robots.txt` `Allow`/`Disallow` checks on crawled URLs, sitemap URLs returning non-200 or `noindex`, orphan sitemap URLs (no inbound links seen among crawled pages), and HTTPS/HSTS/security headers (`Strict-Transport-Security`, `Content-Security-Policy`, `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`).
- **Broken link verification:** Verifies uncrawled internal links (and outbound external links when `checkExternalLinks` is enabled) with bounded concurrency and a polite delay.
- **Health score, prioritized issues & HTML report:** Outputs a `0–100` `healthScore`, severity-ranked `prioritizedIssues` (`critical`, `warning`, `notice`), a Slack/webhook-ready `slackSummary` string, a JSON `OVERVIEW` record, and a readable HTML report saved as `OUTPUT_REPORT` in the default key-value store.
- **Optional run comparison:** Pass `previousDatasetId` from an earlier run to diff `newIssues`, `fixedIssues`, `pagesAdded`, `pagesRemoved`, and `previousHealthScore`.

### Input

| Field | Type | Default | Required | Notes |
| --- | --- | --- | --- | --- |
| `startUrl` | string | `https://example.com` | Yes | Absolute `http` or `https` URL. |
| `maxPages` | integer | `25` | No | Maximum same-origin HTML pages to crawl (1–200). |
| `checkExternalLinks` | boolean | `false` | No | If `true`, also check unique off-site links for 4xx/5xx or network errors. |
| `maxLinkChecks` | integer | `200` | No | Maximum uncrawled internal/external links to verify (0–1000). |
| `crawlConcurrency` | integer | `3` | No | Concurrent requests during crawling (1–5). |
| `requestDelayMs` | integer | `50` | No | Polite pause in milliseconds between request batches and link checks (0–2000). |
| `previousDatasetId` | string | — | No | Optional Apify dataset ID from a prior run to compare new and fixed issues. |

Example input:

```json
{
  "startUrl": "https://example.com",
  "maxPages": 25,
  "checkExternalLinks": false,
  "crawlConcurrency": 3,
  "requestDelayMs": 50
}
```

### Output

1. **Default Dataset:** One `type: "page"` item per crawled page, followed by a `type: "summary"` item containing `healthScore`, `prioritizedIssues`, `issueCountsBySeverity`, `slackSummary`, and `reportUrl`.
2. **HTML Report (`OUTPUT_REPORT`):** Saved in the default key-value store (`text/html`) and linked in the Actor Output tab.
3. **JSON Summary (`OVERVIEW`):** Saved in the default key-value store (`application/json`).

Example page item (truncated):

```json
{
  "type": "page",
  "url": "https://example.com/",
  "finalUrl": "https://example.com/",
  "statusCode": 200,
  "redirected": false,
  "redirectLoop": false,
  "responseTimeMs": 142,
  "pageSizeBytes": 1256,
  "inSitemap": false,
  "blockedByRobots": false,
  "title": "Example Domain",
  "titleLength": 14,
  "h1Count": 1,
  "lang": "en",
  "hasOpenGraph": false,
  "hasStructuredData": false,
  "issues": ["missing_meta_description", "missing_canonical", "missing_viewport"],
  "notices": ["title_too_short", "missing_og_tags", "missing_twitter_tags", "missing_structured_data"],
  "criticalCount": 0,
  "warningCount": 3,
  "noticeCount": 4,
  "issueCount": 3,
  "ok": false
}
```

### Limitations

- **No JavaScript execution:** Uses HTTP `fetch` + Cheerio HTML parsing, so client-side-only SPAs that render titles, headings, or links exclusively in JavaScript will not be evaluated after hydration.
- **Crawl cap:** Checks up to `maxPages` (max `200`) HTML pages and up to `maxLinkChecks` (max `1000`) uncrawled link targets per run to stay fast and lightweight. Orphan sitemap detection only reflects internal links discovered within the crawled page sample.
- **Public access only:** Does not log in, bypass access controls, solve CAPTCHAs, or use residential proxies. Only audit websites you own or have permission to test.

### Development & Testing

Built with AI coding tools and personally tested against local HTTP test fixtures (12 automated unit and integration tests covering crawling, gzipped sitemaps, robots rules, SEO/header checks, redirect loops, run diffs, and HTML escaping) as well as live public sites (`example.com`, `halden-car-leads.vercel.app`, and `www.python.org`).

More public demos and automation tools: [github.com/bauigal](https://github.com/bauigal).

# Actor input Schema

## `startUrl` (type: `string`):

The page or site to start from. robots.txt and sitemaps (.xml and .xml.gz) are fetched from the same origin. Only same-origin HTML pages are crawled.

## `maxPages` (type: `integer`):

Maximum number of same-origin HTML pages to crawl (1–200).

## `checkExternalLinks` (type: `boolean`):

If true, also check unique outbound off-site links for 4xx/5xx or connection errors.

## `maxLinkChecks` (type: `integer`):

Maximum number of uncrawled internal and external links to verify via HEAD/GET (0–1000).

## `crawlConcurrency` (type: `integer`):

Number of concurrent HTTP requests during crawling (1–5).

## `requestDelayMs` (type: `integer`):

Polite pause in milliseconds between request batches and link checks (0–2000).

## `previousDatasetId` (type: `string`):

Optional Apify dataset ID from an earlier run of this Actor to compare new and fixed issues.

## Actor input object example

```json
{
  "startUrl": "https://example.com",
  "maxPages": 25,
  "checkExternalLinks": false,
  "maxLinkChecks": 200,
  "crawlConcurrency": 3,
  "requestDelayMs": 50
}
```

# Actor output Schema

## `report` (type: `string`):

Self-contained HTML report with health score, prioritized issues, and page-by-page breakdown.

## `overview` (type: `string`):

JSON summary including healthScore (0-100), prioritizedIssues, comparison, and slackSummary.

## `pages` (type: `string`):

One dataset item per crawled page, plus a final summary item (type=summary).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrl": "https://example.com",
    "maxPages": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("wearable_drift/site-health-audit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrl": "https://example.com",
    "maxPages": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("wearable_drift/site-health-audit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrl": "https://example.com",
  "maxPages": 25
}' |
apify call wearable_drift/site-health-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wearable_drift/site-health-audit"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bUu42AaW020orH4x2/builds/1oJzHZdvACTA3GdU8/openapi.json
