Git Product home page Git Product logo

sitemap's Introduction

Sitemap

This extension will automatically create XML sitemaps for your Bolt sites. After enabling the extension, go to http://example.org/sitemap.xml to see it.

The bigger search-engines like Google and Bing will automatically pick up your sitemap after a while, but it's always a good idea to explicitly tell the search engines where to find it. To do so, this extension automatically adds the link to the <head> section of your pages:

<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml" />

Apart from that, it's good practice to also add the following line to your robots.txt file:

Sitemap: http://example.org/sitemap.xml

Obviously, you should replace 'example.org' with the domain name of your website.

This extension adds a 'route' for /sitemap.xml and /sitemap by default, but it has lower priority than user defined routes.

If you use the pagebinding in routing.yml, or anything similar route that would match 'sitemap' first, you will need to add the following above that route. You should also do this if you have an extension that might override the default routing, like the AnimalDesign/bolt-translate extension.

sitemap:
  path: /sitemap
  defaults: { _controller: sitemap.controller:sitemap }

sitemapXml:
  path: /sitemap.xml
  defaults: { _controller: sitemap.controller:sitemapXml }

Note, if you have a ContentType with the property searchable: false, that content type will be ignored.

Advanced links list control

If you have your own bundled extension you can add, remove or change links before the sitemap is rendered. You need to subscribe to the SitemapEvents::AFTER_COLLECTING_LINKS event. The object you will get is an instance of SitemapEvent class which has a getLinks method that returns a MutableBag object. The last one is an array-like list of links. See example:

protected function subscribe($dispatcher)
{
    $dispatcher->addListener(SitemapEvents::AFTER_COLLECTING_LINKS,
        function ($event) {
            /** @var SitemapEvent $event */
            $links = $event->getLinks();
            $links->add([
                'link'  => '/lorem-ipsum',
                'title' => 'Hello World!',
                'depth' => 1,
            ]);
        }
    );
}

Sitemap stylesheets

You can customize the sitemap with an xslt stylesheet if you copy the templates/sitemap_xml.twig file and the web/sitemap.xsl file to your theme directory and by adding the xsl-stylesheet declaration after the xml declaration so the first two lines of the themes/{yourthemename}/sitemap_xml.twig look like:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="{{ paths.theme }}/sitemap.xsl"?>

sitemap's People

Contributors

bobdenotter avatar evertalbers avatar gwendolenlynch avatar herveemagma avatar jadwigo avatar leonb avatar maelstromeous avatar marcingajda avatar margot-vogo avatar phillippohlandt avatar sahassar avatar sbani avatar svanterichter avatar xiaohutai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sitemap's Issues

Custom Route's

Hello,

I have one hard coded route to an /contact page. Like this:

contact:
path: /contact
defaults: { _controller: 'Bolt\Controllers\Frontend::template', template: 'contact' }

The above route is not shown in the Sitemap. Is there a way to add this to the sitemap?

How can i have custom the template?

Hi, greate extension.

I want to do some custom in the twig template, so how can I do this without modify the original file in this extension?

Installation fails

Installation stucking on: Generating autoload files
After reloading extensions overview page you get an error and no extensions list:
Warning: set_time_limit(): Cannot set max execution time limit due to system policy in /..../extensions/vendor/bolt/sitemap/Extension.php on line 10

(Bolt 2.2.7)

Warning: in_array() expects parameter 2 to be array, null given in >>/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61

Warning: in_array() expects parameter 2 to be array, null given in /home/lijn/vhosts/hikingmom.eu/extensions/vendor/bolt/sitemap/Extension.php on line 61
http://www.hikingmom.eu/ http://www.hikingmom.eu/entries http://www.hikingmom.eu/entry/finding-a-hike-wandelzoekpagina 2015-02-02T16:00:49+00:00 http://www.hikingmom.eu/entry/geocaching 2015-01-31T13:22:43+00:00 http://www.hikingmom.eu/entry/dutch-dunes-meijendel 2015-01-26T16:11:41+00:00 http://www.hikingmom.eu/entry/howto-download-a-map-for-offline-use-with-locus-map-for-android 2015-01-23T12:08:51+00:00 http://www.hikingmom.eu/entry/quechua-forclaz-900-softshell-jacket-for-kids 2015-01-22T14:11:26+00:00 http://www.hikingmom.eu/entry/how-to-make-hiking-with-kids-fun 2015-01-21T15:06:07+00:00 http://www.hikingmom.eu/entry/hi-im-a-mom-and-i-like-to-hike 2015-01-21T09:12:36+00:00 http://www.hikingmom.eu/page/privacy 2015-01-21T22:05:55+00:00 http://www.hikingmom.eu/page/about 2015-01-21T14:07:08+00:00

All thumbnails Bolt generates are listed in sitemap.xml

All thumbnails Bolts generates are listed in sitemap.xml and to me that seems unnecessary. I don't want Google to index thumbnails, because it are a lot of useless url's. Excluding them in the extensions config file doesn't exclude them from the list. Currently I use version 2.2.3 with Bolt 3.4.1.

The missing link

After installing Sitemap 2.0.5 on Bolt 3.2.5 I get a missing link in the confirmation box. ("...docs can be found via the following link." and then nothing). See Dutch screenshot.

bolt_uitbreiden_ bolt-_2017-01-16_18 20 22 jpeg

missing_link_cl

Contenttypes with viewless: true are included

If I set a contenttype to have no view (i.e. viewless: true in contenttypes.yml), it doesn't have a URL, but this extension lists them anyway - just with their URL as the root URL.

It's easy enough to add it to the excluded contenttypes, but doing this automatically would be nice!

Wrong url when using translations extension

Sitemap places a link to the location of sitemap.xml in the of the page automatically.
This gives a wrong url when used in combination with the Translate extension

The standard code placed by the Sitemap extension:
<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml" />

The output when used in combination with Translate extension:
<link rel="sitemap" type="application/xml" title="Sitemap" href="http://my.site/nlsitemap.xml">

Error when rendering sitemap.xml

Using strict_variables set to true, I get the following warning when I try to load /sitemap.xml.

Warning: Key "alt" for array with keys "file" does not exist in "assets/sitemap_xml.twig" at line 25 #0 /websites/bolt1/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code(91): Twig_Template->getAttribute(Array, 'alt', Array) #1 /websites/bolt1/vendor/twig/twig/lib/Twig/Template.php(381): __TwigTemplate_123c1abff86fa216361224d9a5742509575092be54e4acd1d46241af86f4ece6->doDisplay(Array, Array) #2 /websites/bolt1/vendor/twig/twig/lib/Twig/Template.php(355): Twig_Template->displayWithErrorHandling(Array, Array) #3 /websites/bolt1/vendor/twig/twig/lib/Twig/Template.php(366): Twig_Template->display(Array) #4 /websites/bolt1/src/Response/BoltResponse.php(187): Twig_Template->render(Array) #5 /websites/bolt1/src/Response/BoltResponse.php(166): Bolt\Response\BoltResponse->compile() #6 /websites/bolt1/src/Response/BoltResponse.php(152): Bolt\Response\BoltResponse->getContent() #7 /Users/benjam in /websites/bolt1/src/Response/BoltResponse.php on line 201
Key "alt" for array with keys "file" does not exist

[Question/Bug] HTTP being used on HTTPS page when creating link to Sitemap

I've just started using this plugin on a website that I'm attempted to put live. On the live system, the website is running over HTTPS (and most links work fine). However, the canonical link from Bolt and the created link for the sitemap from this plugin both use http:// for the link. Not a huge hardship, as they will be redirected. However, I'm wondering where this plugin pulls the domain from, and if I'm missing a configuration step somewhere.

Thanks in advance for any insights you may have!

PHP in_array() errors occur when config ignore value is blank

Sample config:

# sitemap settings

template: sitemap.twig
xml_template: sitemap_xml.twig

ignore:

## ignore by "slug" of contenttype
ignore_contenttype:
  - keyfacts
  - testimonials

If ignore: is kept like it is above, it will result in the following error currently:

Warning: in_array() expects parameter 2 to be array, null given in /{PATH}/extensions/vendor/bolt/sitemap/src/SitemapExtension.php on line 177

Commenting out ignore with #ignore resolves the issue.

Generated Sitemap is incorrect with translate extension

I am using Sitemap version 2.3.0 and Translate version 4.1.1 on my Bolt website and the generated sitemap.xml file is using wrong URLs.

All URLs in my sitemap are like this:

<url>
<loc>http://www.website.com/en/en/pages</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>

The language is repeated 2 times en/en/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.