OpenAI Metatag Helper adds a "Generate Metatags with OpenAI" button to Backdrop node edit forms and an option to auto-generate missing meta tags on save. It uses the site's configured OpenAI integration to produce SEO-friendly values (title, description, open-graph fields, keywords) and populates Metatag fields where appropriate.
This module is small and focused: it integrates with the openai module for API access, the metatag module for field rendering, and the key module for secure API key storage. It never overwrites existing tag values — only empty text-like metatag fields are populated.
- Enable the required modules:
openai,metatag, andkey. - Enable
OpenAI Metatag Helper(theopenai_metatagmodule). - Ensure Metatag fields are available on the content types you want to use.
- Configure OpenAI credentials using the
keyoropenaimodule as usual. - Visit Admin -> Configuration -> Open AI -> OpenAI Metatag Assistant (
admin/config/openai/metatag) to:- Toggle per-content-type enablement.
- Turn on
Auto-generate meta tags on save(module default on install). - Select the AI model and
AI max tokensused for generation.
- Give users the permission
Generate metatags with openai(and ensure they haveEdit meta tagsorAdminister meta tags).
- Edit a node that has Metatag support.
- Click the "Generate Metatags with OpenAI" button in the Metatag fieldset to populate available text fields via AJAX.
- Review and save — the module does not overwrite non-empty metatag values.
- If
Auto-generate meta tags on saveis enabled, missing text-like tags will be filled duringhook_node_presave().
- Admin page:
openai_metatag_settings_form()inopenai_metatag.module(path:admin/config/openai/metatag). - Button injection: the module attaches both
hook_form_alter()and an#after_buildhandler (openai_metatag_after_build) to ensure the Generate button is added after Metatag builds its UI. - Text extraction:
openai_metatag_collect_text_from_values()andopenai_metatag_collect_text_from_entity()recursively gather content to provide context to the model (limits are applied to avoid token overuse). - Model selection: module-level options fall back to
openai.settingswhen not set; seeoptions.ai_modelandoptions.ai_max_tokensin the settings form. - Permission: the custom permission is
generate metatags with openai(seeopenai_metatag_permission()). - Logging/diagnostics: the module uses Backdrop
watchdog()calls for debug/error information if generation or form injection fails.
- Backdrop CMS 1.x
- Modules:
openai,metatag,key(declared inopenai_metatag.info).
- If the Generate button is not visible: confirm the Metatag fieldset is enabled for the content type and the current user has
Edit meta tagsandGenerate metatags with openaipermissions. - If generation fails: check that the OpenAI API key is configured (the module reads keys via the
keyintegration) and inspect logs forwatchdog()entries.
openai_metatag.module— main logic (form alters, AJAX, generation and presave behavior).openai_metatag.install— install/update hooks (default settings).openai_metatag.info— module metadata and declared dependencies.
- Install this module using the official Backdrop CMS instructions.
Bugs and feature requests should be reported in the Issue Queue.
Inspired by the Metatag AI module in Drupal.
This project is GPL v2 software. See the LICENSE.txt file in this directory for the full text.