MOD: Include subpages in SimpleSEO

Post Reply
grimblefritz
Posts: 16
Joined: Tue Apr 25, 2023 1:21 pm

MOD: Include subpages in SimpleSEO

Post by grimblefritz »

The way I'm using WCMS, I have a hidden top-level menu item that does nothing but hold subpages I don't want in the menu. I would, however, like to have the subpages (that are not themselves hidden) in the sitemap.

SimpleSEO doesn't descend into the subpages. It only looks at the top level. So, this mod is good for that, too.

The following mod drills into the subpages, and it is recursive. You can have as many levels of subpages as you need.

This is for the version 3.2.1 of simple-seo.php

Find the following comment and foreach:

Code: Select all

    // CMS pages
    foreach ($Wcms->get('config', 'menuItems') as $item) {
and replace the entire foreach with this:

Code: Select all

    foreach ($Wcms->get('config', 'menuItems') as $item) {
        simpleSeoPage($item, $output, $BASE_URL);
    }
At the top of the script, after the global $Wcms, add this function:

Code: Select all

function simpleSeoPage($item, &$output, $BASE_URL) {
    if ($item->visibility !== 'hide') {
        $output[] = $BASE_URL . $item->slug;
    }
    foreach ($item->subpages as $subpage) {
        simpleSeoPage($subpage, $output, $BASE_URL . $item->slug . '/');
    }
}
The sitemap.txt will now include any subpages that are not hidden.

Ideally, if someone would like to tackle it (I'm not interested), on the admin page there should be a checkbox for "Include subpages?"
rao1223
Posts: 1
Joined: Mon Dec 04, 2023 1:19 pm

Re: MOD: Include subpages in SimpleSEO

Post by rao1223 »

SEO OF SUBPAGES

SEO is not a specific tool or technology; it might be a term used in various contexts. If you're referring to a specific platform or library, please provide more details so I can offer more accurate assistance.

Assuming you are working with a website and want to include subpages for search engine optimization (SEO), one common approach is to ensure that your site has a clear and organized structure. Additionally, you can create a sitemap and submit it to search engines to help them discover and index your subpages.

Here's a general example of how you might structure a simple HTML page with subpages:

html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Your website description goes here">

<!-- Other meta tags for SEO -->

<title>Your Website Title</title>
</head>
<body>
<header>
<!-- Your header content -->
</header>

<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/services">Services</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>

<main>
<!-- Main content of your pages goes here -->

<!-- For example, the "About" page -->
<section id="about">
<h1>About Us</h1>
<!-- About page content -->
</section>

<!-- For example, the "Services" page -->
<section id="services">
<h1>Our Services</h1>
<!-- Services page content -->
</section>

<!-- For example, the "Contact" page -->
<section id="contact">
<h1>Contact Us</h1>
<!-- Contact page content -->
</section>
</main>

<footer>
<!-- Your footer content -->
</footer>
</body>
</html>
In this example, each page is represented by a separate section (<section>), and the navigation menu (<nav>) includes links to these pages. Make sure to replace the placeholder content with your actual content and adapt the structure based on your specific needs.

If you have a different context or platform in mind, please provide more details so I can give more relevant guidance.
Image
Post Reply