Skip Navigation

Modifying Results and Wrap Up Laravel Sitemap

In the fourth video of our "Laravel Sitemap" series, "Modifying Results and Wrap Up," CodeTime instructor Trevor Greenleaf shows you how you might add additional pages or remove pages from your sitemap.

Transcript

In the last episode I showed you how to set up a console Command to use sitemap. And we integrated into the kernel by saying, "schedule command sitemap generate weekly." Now you got to remember though you need to set up your Cron to reference the kernel steel, so that it knows the hit this page to know to check on it. It's not just going to automatically do it. If you're using level forge, they have that Cron tab in there, or Scheduler tab where you're going to need to specify the website or the domain name, and then the path, it's pretty easy to go and configure that. And you can take a look at how to do that on level forge. We have a code time series on that here on code time. So again, configure that now you're set. Now it's going to go and run whether you're using something else, maybe you're on GoDaddy or maybe... Hopefully you're not, but maybe you're on something like that or a regular DigitalOcean you'll need to go and manually set that up to hit that Cron will hit this page to go and run.

Okay. So from this, I want to talk about a little bit... We're leaving out some links. So sometimes you have pages, not necessarily that they're secure data. Obviously you wouldn't want people to have access to it or bots to have access if it's securing data of some type that you didn't want people to know about, but maybe it's not something that you want to go and push out onto a search engine. So... or just make it known that that page is so available. So you can leave out some links here pretty easily by passing in a has crawled method here. And then it takes the current URL that it's referencing. And if the URL segment, it's going to look at that segment, and that's segment one. So, that's, slash contact then return. And that [inaudible 00:01:47] is going to return the URL.

And then I do the same thing right to file sitemap path. You also have a should crawl. So same thing create, should crawl function URL. And then it gives you a little note. All pages will be solved except the contact page. A little bit different way to go and do it. And then in here it says URL segment one does not equal the contact page. You maybe want to take this and set this up to be something like an inner lay function. If you have a bunch of pages that you want to exclude and you're referencing the segment, but as you can see, very easily kind of go and configure that. The other thing, if you have a giant site, you might want to limit the number of pages getting crawled, and you can set a set maximum crawl count.

Now of course, there's JavaScript. And this one's a sort of a mixed sort of thing on whether it should execute JavaScript. If you have some pages and the links and the content there, they get produced via JavaScript and whether or not you want to allow executing of the JavaScript when it goes and runs, you have the option to go and configure that. And then finally I want to talk about manually adding links. So sometimes it's just not going to find the pages for whatever reason, or you just want to make sure that it adds it. You can manually add pages. So sitemap, generator, create, get sitemap. It's going to actually go and grab the sitemap. And then we can say add URL. And this is that basic URL facade create extra page. And then we can set a priority for that page and then write it to the file just as we did before, or adding alternates to links, same kind of setup, add an alternative extra page.

And now, so if you're doing localization maybe, that'd be a good way to go in and configure that, so that you have those alternatives via an L or how else, maybe you need maybe alternatives for a page I don't know. Other than localization I don't sure why you would have an alternative to a page as that might actually hurt your Google ranking. Well, and of course, finally, you can manually make a sitemap if you wanted to by just specifying the pages to add and then write it to the files. So that's pretty much it, again, this isn't that complex of package. You might need to configure it a little bit with some PHP code to fit your needs. But for me, most of the time, it's just been just about this and I haven't needed to, or should I say this I haven't needed to maybe run any additional lines or add to it.

I might exclude a couple of times and I have a project with localization that involved again, those language alternatives. But other than that, haven't really needed to do much more than this to set it up so you can see it's very easy to go and do. So with that, I like to say one final note is definitely, if you're using level sitemap, try to send a postcard out to them. That'd be really awesome, again yeah, there's no way to trace it, see if you're using it and didn't send a postcard, but I think it'd be a nice sort of gesture and to say, hey, look here... I think that makes them feel really good to says, the work, the hard work that they put into to creating these packages, making it easier for you to code things. They least see that recognition in that people care enough to send a postcard. So at Speedy level sitemap for level sitemap creation, hope you enjoying and you're able to create some awesome sitemaps.