mcpField
B
bitrix-seo

bitrix-seo

github.com/bxmaximumMarketing & growth47265 installsUpdated 2w ago
Repository

About bitrix-seo

An SEO module skill for Bitrix developers covering sitemap generation, robots.txt rules, and search-engine site data. It explains background and CLI step-by-step builds, and clarifies that page metadata and redirects belong to other modules or mechanisms.

Key features

  1. 01Generate sitemaps with background jobs
  2. 02Run sitemap generation in steps
  3. 03Read and update robots.txt rules
  4. 04Query search-engine site data
  5. 05Locate redirect handling outside SEO

Use cases

  1. 01Regenerate a sitemap through background jobs
  2. 02Add a sitemap URL to robots.txt
  3. 03Run sitemap steps from the CLI
  4. 04Identify the module for page metadata

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/bxmaximum/bitrix-framework-skills --skill bitrix-seo

After installing, type/bitrix-seoin Claude Code to confirm it loaded.

Details

From the project README

SEO module (seo)

Baseline: main 23.0+ · Verified: seo 26.100.0, main 26.800.0

Loader::includeModule('seo') before any class below. Page title/description of iblock content is not stored here: InheritedProperty in bitrix-iblocks (rules/query-seo-perf.md). Landing counters/meta: hooks in bitrix-landing.

Sitemap

ClassRole
Bitrix\Seo\Sitemap\Internals\SitemapTableb_seo_sitemap rows: SITE_ID, ACTIVE, NAME, DATE_RUN, serialized SETTINGS
Bitrix\Seo\Sitemap\JobBackground build by agent: markToRegenerate(), addJob(), doJobAgent(), STATUS_*
Bitrix\Seo\Sitemap\GeneratorOne step of a build: init($step, $state), run(), getStep(), getState()
Bitrix\Seo\Sitemap\Type\StepStep values: Step::STEPS[Step::STEP_INIT] = 0 … Step::STEPS[Step::STEP_INDEX] = 100

Settings saved from a form go through SitemapTable::prepareSettings($settings). Don't write your own XML writer.

Background (preferred): Job::markToRegenerate($sitemapId) creates the job and an agent (first run in 60 s, then every second) that runs one step per hit until done. Agents must run (cron in production, bitrix-background-jobs).

In-process (CLI, stepper): run() does one step of about 13 s and returns false only on error. The build is finished when getStep() reaches Step::STEPS[Step::STEP_INDEX]. Build a new Generator per step and carry step + state, as Job::doStep() does; across HTTP hits, persist both.

use Bitrix\Seo\Sitemap\Generator;
use Bitrix\Seo\Sitemap\Type\Step;

$step = Step::getFirstStep();
$state = [];
do {
    $generator = (new Generator($sitemapId))->init($step, $state);
    if (!$generator->run()) {
        throw new \RuntimeException($generator->getStatusMessage());
    }
    $step = $generator->getStep();
    $state = $generator->getState();
} while ($step < Step::STEPS[Step::STEP_INDEX]);

With SETTINGS['ROBOTS'] === 'Y' the last step adds the Sitemap: line to robots.txt itself.

Admin pages: /bitrix/admin/seo_sitemap.php, seo_sitemap_edit.php.

robots.txt

use Bitrix\Seo\RobotsFile;

$robots = new RobotsFile('s1'); // site document root robots.txt
$robots->addRule([RobotsFile::SITEMAP_RULE, 'https://example.com/sitemap.xml']);
$sitemaps = $robots->getRules(RobotsFile::SITEMAP_RULE);

RobotsFile extends Bitrix\Main\IO\File; SECTION_RULE = User-Agent. Admin: seo_robots.php.

Webmaster and search engines

  • Registry: Bitrix\Seo\SearchEngineTable (b_seo_search_engine, key CODE).
  • Engines in Bitrix\Seo\Engine\: Yandex (ENGINE_ID = 'yandex'), Google ('google'), YandexDirect, base YandexBase.
  • Bitrix\Seo\Webmaster\Service::getSites() — hosts with bound/verified flags.
  • Bitrix\Seo\Service::REDIRECT_URI (/bitrix/tools/seo_client.php) is the OAuth callback, not an HTTP redirect.
  • Legacy helpers (compat only): CSeoKeywords (Add/Update/GetByURL), CSeoPageChecker, CSeoUtils::getDomainsList(). Admin: seo_tools.php, seo_search_yandex.php, seo_search_google.php.
  • Ads/retargeting namespaces (Bitrix\Seo\Retargeting\, LeadAds\, Analytics\) are product integrations; skip them for sitemap/robots work.

Redirects: no API here

The kernel has no seo table for 301/302 rules. Don't invent SeoRedirectTable.

NeedWhere
Crawl allow/deny, sitemap URLRobotsFile, sitemap SETTINGS
Open-redirect allow-listsecurity module: CSecurityRedirect, Bitrix\Security\RedirectRuleTable
Page movedweb server rule, route (bitrix-routing) or LocalRedirect in a component

After URL changes: fix links in content, Job::markToRegenerate(), adjust robots.

Checklist

  • Loader::includeModule('seo') before Sitemap/Robots/Engine classes.
  • Sitemap rows via SitemapTable; builds via Job or a Generator step loop that carries step + state.
  • run() === false handled as an error, not as "more steps".
  • Iblock meta via InheritedProperty, not custom b_seo_* columns.
  • No invented redirect CRUD in seo.

Comments

Markdown supported