Skip to content

Releases: webitproff/seoarticle

Release list

First Release

Choose a tag to compare

@webitproff webitproff released this 21 Apr 22:07
5cf8055

SeoArticle Plugin for Cotonti

The SeoArticle plugin enhances the SEO capabilities of the Cotonti CMF's Pages module by adding meta tags, Open Graph, Twitter Card, Schema.org structured data, keyword extraction, reading time estimation, and related articles functionality.

Tested

Cotonti CMF v.0.9.26 beta on PHP v.8.2.25

File Structure

plugins/seoarticle/
├── inc/
│   └── seoarticle.functions.php       # Functions for keyword extraction and reading time estimation
├── lang/
│   └── seoarticle.ru.lang.php         # Russian translations and stop words for keyword extraction
│   └── seoarticle.en.lang.php         # English translations and stop words for keyword extraction
├── seoarticle.header.tags.php         # Overrides HEADER_META_DESCRIPTION and HEADER_META_KEYWORDS
├── seoarticle.page.main.php           # Adds Open Graph, Twitter Card, and Schema.org meta tags
├── seoarticle.page.tags.php           # Defines page tags (e.g., PAGE_READ_TIME, PAGE_AUTHOR, RELATED_ROW_*)
└── seoarticle.setup.php               # Plugin configuration and setup

File Descriptions

  • seoarticle.setup.php: Defines plugin metadata (name, version, author) and dependencies.
  • seoarticle.header.tags.php: Overrides {HEADER_META_DESCRIPTION} and {HEADER_META_KEYWORDS} for meta tags, ensuring single-line descriptions and keyword extraction.
  • seoarticle.page.main.php: Generates Open Graph, Twitter Card, and Schema.org meta tags, including title, description, keywords, author, and image.
  • seoarticle.functions.php: Contains cot_extract_keywords (extracts keywords with stop words filtering) and cot_estimate_read_time (estimates reading time, handles HTML/BBCode).
  • seoarticle.ru.lang.php: Provides Russian translations for labels (e.g., "Related articles") and stop words for keyword extraction.
  • seoarticle.en.lang.php: Provides English translations for labels (e.g., "Related articles") and stop words for keyword extraction.
  • seoarticle.page.tags.php: Adds tags like {PAGE_READ_TIME}, {PAGE_AUTHOR}, and {RELATED_ROW_*} for related articles (See seoarticle.page.tags.php ).

Features

  • Meta Tags:
    • Generates <meta name="description"> and <meta name="keywords"> based on page_metadesc, page_keywords, or extracted from page_text.
    • Ensures single-line descriptions without line breaks.
  • Open Graph and Twitter Card:
    • Adds og:title, og:description, og:image, twitter:card, etc., for social media sharing.
  • Schema.org:
    • Includes structured data for articles (headline, description, keywords, author, image).
  • Keyword Extraction:
    • Automatically extracts keywords from page_text using cot_extract_keywords if page_keywords is empty.
    • Supports stop words (e.g., "и, в, на") defined in seoarticle.ru.lang.php.
  • Reading Time Estimation:
    • Calculates reading time with cot_estimate_read_time (200 words/minute, minimum 1 minute).
    • Handles HTML and BBCode in page_text.
  • Related Articles:
    • Displays related articles with title, description, and image (page_link_main_image).
  • Author Information:
    • Shows author name from cot_users or "Unknown author" if not found.

Installation

Prerequisites

  • Cotonti CMF (tested with Siena).
  • Pages module enabled.
  • MySQL/MariaDB database.

Steps

  1. Download the Plugin:

    • Clone or download the repository from GitHub:

      git clone https://github.com/webitproff/seoarticle.git
    • Or download the ZIP and extract to /plugins/seoarticle/.

  2. Copy Files:

    • Place the seoarticle folder in /plugins/ of your Cotonti installation:

      public_html/plugins/seoarticle/
      
  3. Install the Plugin:

    • Go to Administration → Extensions in the Cotonti admin panel.
    • Find SeoArticle in the list and click Install.
    • The plugin will register itself using seoarticle.setup.php.
  4. Configure Extra Fields:

    • Go to Administration → Structure → Pages → Extra fields.
    • Add an extra field for images:
      • Code: link_main_image
      • Type: URL
      • Description: Main image for Open Graph and related articles
    • Ensure page_metadesc, page_metatitle, and page_keywords are available (default in Cotonti).
  5. Update Templates:

    • Open /themes/CleanCot/header.tpl and ensure it includes:

      <meta name="description" content="{HEADER_META_DESCRIPTION}" />
      <meta name="keywords" content="{HEADER_META_KEYWORDS}" />
      <!-- IF {PHP.out.meta} -->{PHP.out.meta}<!-- ENDIF -->
    • Open /themes/cleancot/page.tpl (download theme) and add:

         		<!-- IF {PHP|cot_plugin_active('seoarticle')} -->
         		<!-- IF {RELATED_PAGES} -->
         		<div class="related">
         			<!-- BEGIN: MAIN.RELATED_PAGES.RELATED_ROW -->
         			<a href="{RELATED_ROW_URL}">
         				<div class="position-relative overflow-hidden rounded-5 shadow-bottom" style="aspect-ratio: 2 / 1;">
         					<!-- Условие Cotonti: проверка наличия главного изображения через экстраполяцию -->
         					<!-- IF {RELATED_ROW_LINK_MAIN_IMAGE} -->
         						<!-- Главное изображение страницы из Cotonti, адаптивное с обрезкой -->
         						<img src="{RELATED_ROW_LINK_MAIN_IMAGE}" alt="{RELATED_ROW_TITLE}" class="img-fluid object-fit-cover">
         					<!-- Альтернатива: если главного изображения нет -->
         					<!-- ELSE -->
         						<!-- Дефолтное изображение из темы Cotonti -->
         						<img src="{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/img/cotonti-cleancot.webp" alt="{PAGE_TITLE}" class="img-fluid object-fit-cover">
         					<!-- Конец условия изображения -->
         					<!-- ENDIF -->
         				</div>
         				<h3 class="h5 mb-0">{RELATED_ROW_TITLE}</h3>
         				<p>{RELATED_ROW_DESC}</p>
         			</a>
         			<!-- END: MAIN.RELATED_PAGES.RELATED_ROW -->
         		</div>
         		<!-- ENDIF -->
         		<!-- ENDIF -->

and

<!-- IF {PHP|cot_plugin_active('seoarticle')} -->
  {PAGE_READ_TIME}
<!-- ENDIF -->
  1. Clear Cache:

    • go to Administration → Cache → Clear cache.
  2. Test the Plugin:

    • Create or edit a page in Administration → Pages.
    • Fill page_metadesc, page_keywords, page_metatitle, and page_link_main_image (optional).
    • View the page and check:
      • <meta name="description"> and <meta name="keywords"> in <head>.
      • Open Graph and Schema.org tags.
      • Reading time ({PAGE_READ_TIME}), author ({PAGE_AUTHOR}), and related articles.

Recommendations

  • Use Meta Fields:

    • Always fill page_metadesc, page_keywords, and page_metatitle in the page editor for precise SEO control.
    • Use page_link_main_image for better social media previews.
  • Stop Words:

    • Extend stop words in /plugins/seoarticle/lang/seoarticle.ru.lang.php for better keyword extraction:

      $L['seoarticle_stop_words'] = 'и,в,на,с,по,для,это,как,что,а,у,к,от,до,при,о,без,если';
  • Database Optimization:

    • Ensure indexes on cot_pages (page_id, page_ownerid, page_cat) and cot_users (user_id) for faster queries.
  • Testing:

    • Use browser developer tools to verify meta tags and structured data.
    • Test related articles by creating multiple pages in the same category.

Warnings

  • Template Conflicts:

    • Ensure {HEADER_META_DESCRIPTION} and {HEADER_META_KEYWORDS} are not duplicated in header.tpl to avoid multiple meta tags.
    • Check <head> for duplicate <meta name="description"> or <meta name="keywords">.
  • Extra Fields:

    • If page_link_main_image is not configured, the plugin falls back to /images/default.jpg. Set a valid default image in seoarticle.page.main.php if needed.
  • Performance:

    • Keyword extraction (cot_extract_keywords) may be slow for very long page_text. Limit text length or cache results if necessary.
  • Language Support:

    • The plugin includes only Russian translations (seoarticle.ru.lang.php). Add other languages (e.g., seoarticle.en.lang.php) for multilingual sites.
  • Dependencies:

    • Requires the Pages module. Ensure it is enabled before installation.
    • Database queries assume cot_users and cot_structure tables are intact.

License

BSD License. See LICENSE for details.

Author

webitproff 22 April 2025

#############

Русский

#############

Плагин SeoArticle для Cotonti

Плагин SeoArticle расширяет SEO-возможности модуля Pages в Cotonti CMF, добавляя мета-теги, Open Graph, Twitter Card, структурированные данные Schema.org, извлечение ключевых слов, оценку времени чтения и функционал связанных статей.

Протестировано

Cotonti CMF v.0.9.26 beta на PHP v.8.2.25

Структура файлов

plugins/seoarticle/
├── inc/
│   └── seoarticle.functions.php       # Функции для извлечения ключевых слов и оценки времени чтения
├── lang/
│   └── seoarticle.ru.lang.php         # Русские переводы и стоп-слова для извлечения ключевых слов
│   └── seoarticle.en.lang.php         # Английские переводы и стоп-слова для извлечения ключевых слов
├── seoarticle.header.tags.php         # Переопределяет HEADER_META_DESCRIPTION и HEADER_META_KEYWORDS
├── seoarticle.page.main.php           # Добавляет мета-теги Open Graph, Twitter Card и Schema.org
├── seoarticle.page.tags.php           # Определяет теги страницы (например, PAGE_READ_TIME, PAGE_AUTHOR, RELATED_ROW_*)
└── seoarticle.setup.php               # Конфигурация и установка плагина

Описание файлов

  • seoarticle.setup.php: Определяет метаданные плагина (название, версия, автор) и зависимости.
  • seoarticle.header.tags.php: Переопределяет {HEADER_META_DESCRIPTION} ...
Read more