ranklint init
The first step after installing the CLI. ranklint init asks a few questions and writes ranklint.config.ts into the current directory, then loads it back with the real config loader so you know it is valid.
npx ranklint init
What it asks
- Site url (absolute http/https, validated).
- Do you need a profile for UAT/staging? The UAT url becomes
profiles.uat, applied withranklint audit --profile uat. - Do several apps share this domain? The glob paths of your own section (comma separated) become
apps.self, the rest of the domain becomes a foreign zone. See Zones. - CI provider:
gitlab,githubornone. The snippet is printed, no pipeline file is created or edited. - Enable scheduled production monitoring? Adds
monitorwith fs storage, used byranklint audit --mode monitor.
If ranklint.config.ts already exists, init asks whether to overwrite it; the default answer is no.
What it generates
import { defineRanklintConfig } from '@ranklint/core'
export default defineRanklintConfig({
site: { url: 'https://example.com' },
apps: {
self: { paths: ['/en/market/**', '/ar/market/**'] },
main: { paths: ['/**'], owner: 'external' },
},
monitor: { storage: 'fs', dir: '.ranklint/reports' },
profiles: {
uat: { site: { url: 'https://uat.example.com' } },
},
})
Sections you declined are simply absent: the minimal result is site alone. After writing the file init runs loadRanklintConfig and reports config is valid; when @ranklint/core is not installed yet it prints the hint npm i -D @ranklint/core instead.
Non-interactive mode
| Flag | Description |
|---|---|
--yes | no prompts, requires --url |
--url | production url of the site |
--uat | UAT url, generates the uat profile |
--zones | comma separated globs of your own zone |
--ci | gitlab | github | none, prints the pipeline snippet |
--force | overwrite an existing ranklint.config.ts |
--cwd | directory to create the config in |
npx ranklint init --yes --url https://example.com --uat https://uat.example.com --ci github
Without --yes and without a TTY the command fails with "use --yes with --url", so it never hangs in a pipeline.
CI snippets
GitLab:
include:
- remote: 'https://raw.githubusercontent.com/aakazancev/ranklint/main/presets/gitlab-ci/seo.yml'
seo:audit:
extends: .ranklint-audit
variables:
RANKLINT_URL: https://example.com
GitHub Actions (a reusable workflow, add it to .github/workflows/seo.yml):
name: seo
on: [pull_request]
jobs:
seo:
uses: aakazancev/ranklint/.github/workflows/seo.yml@main
with: { url: 'https://example.com' }
More about the presets in Diff & CI.
Nuxt detection
When the directory has a nuxt.config.ts|js|mjs and @ranklint/nuxt is not in package.json, init finishes with:
Nuxt detected: npx nuxi module add @ranklint/nuxt
The module gives you sitemap, robots and JSON-LD at build time, while the CLI audits the deployed result.