Create sitemap & # 8211; Web diagram for laravel website.

In the content of this article we will go to find out:

Content

  1. What is sitemap.
  2. Effect of Sitemap on website.
  3. Create file sitemap automatically.
  4. Create online sitemap.

1. What is Sitemap:

Sitemap, also known as a sitemap, is exactly the same as the sitemap as a miniature map that gathers the URL of a website, supports the navigation of user behavior on the website while also helping the Google Bot easily crawl and index your website.

screen-shot-2016-10-11-at-10-41-32-am

If you are doing SEO or are learning about SEO, Sitemap is a factor not to be missed for any 1 website. Before going into the sitemap creation, you must understand what the nature of its characteristics is, the benefits it brings to the SEO process.

2. Effect of sitemap on SEO.

Creating a sitemap is important for any 1 website, but it does not directly affect the ranking of the website but it will help navigate user behavior in the best, friendly way with search engines:

screen-shot-2016-10-11-at-10-42-01-am

Sitemap helps declaring search engines (Google, Bing, Coccoc, etc.) diagrams of links in websites that make indexing happen easily and accurately

Improving index speed for websites: Creating a sitemap will help you speed up indexing quickly on pages on the site

Detecting link errors: Google bots encountering non-crawling errors is also inevitable. When creating a sitemap you will control error links more easily

Webmasters can manage their system in an accurate way to decentralize content on the page.

Source seohay.vn

Site map has 2 types, the first one is xml, the second is html. In this article, I will show you how to create a sitemap using xml:

3. Create a sitemap file with laravel code.

Actually creating a sitemap file has many websites on the network that support you to do this, but the disadvantage of it is that it limits the size of your website (ie, maximum number of links on the article), or each When your website has a new post it will not automatically update to the sitemap, it will be inconvenient when every time will have to go to that website and create a sitemap and download and then upload it to your host right.

An automated sitemap with code with any link you want, and you can schedule it to run daily automatically.

In this article I will use the library laravel-sitemap of the author RoumenDamianoff, you can refer to https://github.com/RoumenDamianoff/laravel-sitemap .

A. Library installation

  1. You open the terminal and run the following command:

or manually add the composer.json file to the following code: "roumen / sitemap": "2.6. *"

  1. Run composer update if you add the json file manually.
  2. Add to the Service Provider the following line: Roumen SitemapServiceProvider :: class,
  3. Run the command php artisan vendor: publish –provider = ”Roumen SitemapServiceProvider” to pubic config files.

So we have installed the library, then we will create a command to be able to set the running schedule for this job.

B: Create command

  1. First, run the following command in the terminal: php artisan make: console CreateSiteMap -command = sitemap: create this command will create a file called CreateSiteMap.php in the directory app / console / commands with the following content:

The function handle will be rewritten later:

  1. Edit the .env file in the root directory and config APP_URL if not config – this is your website link configuration.
  2. In the directory of your project run the following command: php artisan sitemap: create .
  3. Type on yourdomain.com/sitemap.xml browser if you see this occurrence means you have succeeded:

36b59caab8514fcab33be999f207d61bc14dbd24

So, the way to create a sitemap by code is fully automated, now you can configure the cron job on your server so that it runs daily or weekly if you want.

4. Create online Sitemap

  1. First go to the website https://www.xml-sitemaps.com/
  2. Fill out the corresponding website and config information:

1792ab5d7a933e0e8c99411aad6ec02dafb81a94

You can refer to the config in the image, then click start it will automatically create a sitemap for your site, any link it finds will be included in this sitemap file:

  1. When it finishes running (usually takes 15 minutes). You download the sitemap file, xml and upload it to your host, the location is the same with the index.php file (public folder).
  2. To test the same type type yourdomain.com/sitemap.xml in the browser, if the xml code appears, you are successful.

Above is the content I want to share, if you have any questions please leave a comment.

Thank for your reading.

ITZone via Viblo

 

Share the news now