Search the Community
Showing results for tags 'sitemap'.
-
Docs & Download: rockettpw/seo/markup-sitemap Modules Directory: MarkupSitemap Composer: rockett/sitemap ⚠️ NEW MAINTAINER NEEDED: Sitemap is in need of developer to take over the project. There are a few minor issues with it, but for the most part, most scenarios, it works, and it works well. However, I'm unable to commit to further development, and would appreciate it if someone could take it over. If you're interested, please send me a private message and we can take it from there. MarkupSitemap is essentially an upgrade to MarkupSitemapXML by Pete. It adds multi-language support using the built-in LanguageSupportPageNames. Where multi-language pages are available, they are added to the sitemap by means of an alternate link in that page's <url>. Support for listing images in the sitemap on a page-by-page basis and using a sitemap stylesheet are also added. Example when using the built-in multi-language profile: <url> <loc>http://domain.local/about/</loc> <lastmod>2017-08-27T16:16:32+02:00</lastmod> <xhtml:link rel="alternate" hreflang="en" href="http://domain.local/en/about/"/> <xhtml:link rel="alternate" hreflang="de" href="http://domain.local/de/uber/"/> <xhtml:link rel="alternate" hreflang="fi" href="http://domain.local/fi/tietoja/"/> </url> It also uses a locally maintained fork of a sitemap package by Matthew Davies that assists in automating the process. The doesn't use the same sitemap_ignore field available in MarkupSitemapXML. Rather, it renders sitemap options fields in a Page's Settings tab. One of the fields is for excluding a Page from the sitemap, and another is for excluding its children. You can assign which templates get these config fields in the module's configuration (much like you would with MarkupSEO). Note that the two exclusion options are mutually exclusive at this point as there may be cases where you don't want to show a parent page, but only its children. Whilst unorthodox, I'm leaving the flexibility there. (The home page cannot be excluded from the sitemap, so the applicable exclusion fields won't be available there.) As of December 2017, you can also exclude templates from sitemap access altogether, whilst retaining their settings if previously configured. Sitemap also allows you to include images for each page at the template level, and you can disable image output at the page level. The module allows you to set the priority on a per-page basis (it's optional and will not be included if not set). Lastly, a stylesheet option has also been added. You can use the default one (enabled by default), or set your own. Note that if the module is uninstalled, any saved data on a per-page basis is removed. The same thing happens for a specific page when it is deleted after having been trashed.
- 189 replies
-
- 18
-
Hey everyone- We recently had a need come up for a website. After launching our website the company hired an SEO specialist who is doing some significant work revising and optimizing content. To help enhance this process I wrote a very simple module that automatically submits the website's sitemap.xml file to Bing and Google when a page is published, or when a page is saved that was already published. As for our reasoning- there's a lot of information available as to why submitting your sitemap regularly can be beneficial. In classic Google style their official documentation says that there "is no guarantee" that submitting a sitemap alone will trigger a re-indexing by Google's bots. That said, devs have done tests where there is a strong correlation between a sitemap submission and activity by Google bots on that website. Google has stated that there is no limit or cap on the number of times you can submit a sitemap so there is no penalty for triggering this for every change. For more details and the hard science visit this excellent article https://trevorfox.com/2018/09/ping-sitemaps-search-engines/ 2021 Update! This module has been rebuilt almost entirely to perform even better and cover more events that can affect sitemap.xml data which makes it more effective for your SEO performance. Previously the module submitted the sitemap.xml URL when a page was saved but has now been expanded to encompass any event that potentially modifies your sitemap and does it more intelligently. These events include: New page is published - New URL created Existing page is unpublished - URL no longer available Existing page is saved - Content on page may have changed Existing page is moved - URL has changed Existing page is deleted - URL no longer exists Existing page is restored - URL is now available ProcessSitemapSubmit also: Checks if sitemap.xml exists/is available Logs submissions and results to sitemap-submit log Allows for the sitemap URL can be specified, defaults to yoursite.com/sitemap.xml Templates can be excluded for pages created/saved that should not be submitted to search engines Hidden pages do not trigger a submission. Supports Bing and Google As always, I'd never share a module with the community that I haven't used in production but I still ask that you test and ensure that it works for you. The repo for this module has a notice that it is still in development but I am going to bring it to a release and add it to the Modules directory soon (i.e. when I have a spare minute). This module should have little to no risk and the best way to test is to check the sitemap-submit logs for successful submissions. I am a big fan of the Sitemap module by @Mike Rockett and use it on all of my sites. The Sitemap module uses caching to deliver your sitemap.xml file efficiently. I've worked with Mike to update his module so that it allows ProcessSitemapSubmit to clear it's cache and deliver the latest changes to search engines. This module is aware of Sitemap and works with zero configuration out of the box. To get this functionality in tandem with ProcessSitemapSubmit, please update the Sitemap module on your site. The Sitemap module is not a requirement for this module to work as long as your website has an available sitemap.xml to submit. Check it out. https://github.com/SkyLundy/ProcessSitemapSubmit Feedback and bug reports welcome!
-
SYNOPSIS A little guide to generating an sitemap.xml using (I believe) a script Ryan originally wrote with the addition of being able to optionally exclude child pages from being output in the sitemap.xml file. I was looking back on a small project today where I was using a php script to generate an xml file, I believe the original was written by Ryan. Anyway, I needed a quick fix for the script to allow me to optionally exclude children of pages from being included in the sitemap.xml output. OVERVIEW A good example of this is a site where if you visit /minutes/ a page displays a list of board meetings which includes a title, date, description and link to download the .pdf file. I have a template called minutes and a template called minutes-document. The first page, minutes, when loaded via /minutes/ simply grabs all of its child pages and outputs the name, description and actual path of an uploaded .pdf file for a visitor to download. In my back-end I have the template MINUTES and MINUTES-DOCUMENT. Thus: So, basically, their employee can login, hover over minutes, click new, then create a new (child) record and name it the date of the meeting e.g. June 3rd, 2016 : --------------------------- OPTIONALLY EXCLUDING CHILDREN - SETUP Outputting the sitemap.xml and optionally excluding children that belong to a template. The setup of the original script is as follows: 1. Save the file to the templates folder as sitemap.xml.php 2. Create a template called sitemap-xml and use the sitemap.xml.php file. 3. Create a page called sitemap.xml using the sitemap-xml template Now, with that done you will need to make only a couple of slight modifications that will allow the script to exclude children of a template from output to the sitemap.xml 1. Create a new checkbox field and name it: sitemap_exclude_children 2. Add the field to a template that you want to control whether the children are included/excluded from the sitemap. In my example I added it to my "minutes" template. 3. Next, go to a page that uses a template with the field you added above. In my case, "MINUTES" 4. Enable the checkbox to exclude children, leave it unchecked to include children. For example, in my MINUTES page I enabled the checkbox and now when /sitemap.xml is loaded the children for the MINUTES do not appear in the file. A SIMPLE CONDITIONAL TO CHECK THE "sitemap_exclude_children" VALUE This was a pretty easy modification to an existing script, adding only one line. I just figure there may be others out there using this script with the same needs. I simply inserted the if condition as the first line in the function: function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; ... ... ... THE FULL SCRIPT WITH MODIFICATION <?php /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * * patch to prevent pages from including children in the sitemap when a field is checked / johnwarrenllc.com * 1. create a checkbox field named sitemap_exclude_children * 2. add the field to the parent template(s) you plan to use * 3. when a new page is create with this template, checking the field will prevent its children from being included in the sitemap.xml output */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; /* Aded to exclude CHILDREN if field is checked */ $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) { $out .= renderSitemapChildren($page); } } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // Example: echo renderSitemapXML(array('/hidden/page/')); In conclusion, I have used a couple different processwire sitemap generating modules. But for my needs, the above script is fast and easy to setup/modify. - Thanks
-
Hello I am using a dynamically created Pagination like: $allImages = $page->VitrineImages; $limit = $page->VitrineImageCount; $start = ($input->pageNum - 1) * $limit; $images = $page->VitrineImages->slice($start, $limit); $total = count($page->VitrineImages); $a = new PageArray(); foreach($images as $unused) $a->add(new Page()); $a->setTotal($total); $a->setLimit($limit); $a->setStart($start); this works fine in the template file to create Pagination in relation to the number of images for that field in the page. But I have problems to include that inside a sitemap template (I am using the code from here -> https://processwire.com/talk/topic/3846-how-do-i-create-a-sitemapxml/?page=1 ) It doesn't create anything when I use the same code in the sitemap.php only replacing the $page variable with $homepage which is defined in _init.php (which is prepended for the sitemap template - and it's inside the $homepage page where I use the pagination in that way) It seems I am missing something (kind of new to processwire) because $a is always 0 when using this code in my sitemap.php file...
-
Is it possible to create a sitemap for only one navigation element? I have several dropdowns, but really need to create a sitemap for each dropdown separately. I know this seems odd, but unfortunately the site is set up kind of weird.
-
Hey guys, I know this isn't really a how to, but I am currently working on a system to inline above the fold css and was needing a json pagelist, and figured I would write something to automate it. I included the ability to flatten the tree or keep it expanded. There is also a filter section where you can exclude individual pages by path, parent, id, or template. This is all pretty bare bones and will pretty much just gives you a json array of your page paths, but that is all I needed. This is working code but you will need to clear out the filters for your own site. <?php /* * JSON SITEMAP GENERATOR * By Sam Fleming -- MUCHDEV * This will create a json sitemap for grunt or other purposes * * option includes flat / expanded. Use however you need * * apply whatever filters you need to exclude in the filter array * curently supports excluding by: * Path * Parrent * ID * Template */ ########################################################### ## SET HERE IF YOU WANT AN EXPANDED OR FLATTENED SITEMAP ## ########################################################### $flatten = true; ########################################################### ## YOUR PAGE FILTERS GO HERE ## ########################################################### $filters = array( "paths" => array( "/processwire/" ), "parents" => array( "3211", "5", "55", "98745" ), "ids" => array( "1123", "5985", "321454", "15885", "321115", "39" ), "templates" => array( "template1", "template2" ) ); function buildSitemap($flatten) { $home = wire('pages')->get('/'); $urls[] = $home->httpUrl; $urls[] = getChildren($home->children); if($flatten){ $flatArray = arrayFlatten($urls); return json_encode($flatArray); }else{ return json_encode($urls); } } function getChildren($pages){ foreach($pages as $page){ //iterate through all the filters in array, and if the type matches then set flag to true $flag = false; foreach($filters as $filter){ switch($filter){ case "paths": foreach($filter as $path){ if($page->path == $path) $flag = true; } break; case "parents": foreach($filter as $parrent){ if($page->parrent == $parrent)$flag = true; } break; case "ids": foreach($filter as $id){ if($page->id == $id)$flag = true; } break; case "templates": foreach($filter as $template){ if($page->template == $template)$flag = true; } break; } } if(!$flag) $urls[] = $page->httpUrl; //if page has children then recurse if($page->numChildren){ $urls[] = getChildren($page->children); } } return $urls; } function arrayFlatten($array) { $return = array(); foreach ($array as $key => $value) { if (is_array($value)){ $return = array_merge($return, arrayFlatten($value)); } else { $return[$key] = $value; } } return $return; } echo buildSitemap($flatten); ?>