Page 1 of 1

Tool to make sitemap.txt files - make_sitemap.php

Posted: Wed Jan 08, 2020 10:35 pm
by hightowe
I wanted to share a little tool that I created to make /sitemap.txt files, to be referenced from your /robots.txt files, from wCMS menu items.

Nothing fancy or special here, just a little tool that I needed as I launched a new site and thought I would share it.

Code: Select all

<?php

################################################################
# Simple program to make a sitemap.txt file from wCMS menuItems.
# Authored Jan-2020 by Lester Hightower
#
# To use, set $BASE_URL as needed for your site, then from the root of
# the wCMS install (location of index.php) run:
#
# prompt> php make_sitemap.php > sitemap.txt
################################################################

const PHPUNIT_TESTING = true; # Prevents normal www behavior
include 'index.php';          # when index.php is included.

$Wcms = new Wcms();
$Wcms->init();

$BASE_URL = 'https://your-site.com';

$output = array( $BASE_URL );
foreach ($Wcms->get('config', 'menuItems') as $item) {
  if ($item->visibility === 'hide') {
    continue;
  }
  array_push($output, $BASE_URL . '/' . $item->slug);
}

print join("\n", $output);

?>

Re: Tool to make sitemap.txt files - make_sitemap.php

Posted: Wed Jan 08, 2020 10:51 pm
by wiz
Hi hightowe, welcome to the community.

Thanks for sharing an awesome tool. I was just dealing with a sitemap and robots.txt a couple of months ago.
Mind sending me your first/last name + website in a private message?

We like to reward active contributors with an honorable mention on the official website:
https://www.wondercms.com/special-contributors

Also, if you've got any feedback on WonderCMS 3.0.x, it's appreciated.

Re: Tool to make sitemap.txt files - make_sitemap.php

Posted: Thu Jan 09, 2020 12:36 pm
by StephanStanisic
Hey hightowe!

Awesome script. Mind me turning it into a plugin?
Could you share a robots.txt that you use for a WonderCMS website?

I think that bundling this into a plugin could help SEO for more WonderCMS users, as installing a plugin isn't that hard anymore with the current installer.

Re: Tool to make sitemap.txt files - make_sitemap.php

Posted: Sat Jan 11, 2020 9:21 am
by wiz
Stephan, in regards to sharing the script, I think the no license attached could mean two things:
1. It's the same license as WonderCMS (MIT), which allows you to fork it as long as you preserve the original author name/link.
2. It's public domain, which also allows you to fork this into a plugin.

I would go on and fork this into a plugin, I believe it would also benefit the original author. :)

Re: Tool to make sitemap.txt files - make_sitemap.php

Posted: Sat Jan 11, 2020 9:58 pm
by hightowe
StephanStanisic wrote: Thu Jan 09, 2020 12:36 pm Hey hightowe!

Awesome script. Mind me turning it into a plugin?
Could you share a robots.txt that you use for a WonderCMS website?

I think that bundling this into a plugin could help SEO for more WonderCMS users, as installing a plugin isn't that hard anymore with the current installer.
StephanStanisic,

See https://adivvyo.com/robots.txt

I have no problem with you turning this into a plugin. Caution probably should be taken, however, to make it be "on demand" publishing of robots.txt and sitemap.txt because doing it automatically, particularly as incremental changes are in the works, is likely not in site owners' best interests. It's not clear to me how to do that today with wCMS plugins, but I am just learning the system...

License for my code here is public domain.

Re: Tool to make sitemap.txt files - make_sitemap.php

Posted: Sun Mar 15, 2020 7:23 pm
by StephanStanisic
So I finally had some free time on hand in order to work on this :D

So here it is, the first version at least.
https://github.com/StephanStanisic/simple-seo

Just really, really simple. It isn't even a class or anything.