Showing posts with label alter custom links in simple sitemap. Show all posts
Showing posts with label alter custom links in simple sitemap. Show all posts

Tuesday 25 August 2020

How to alter or add custom url links in simple sitemap in drupal 8?

 It is very simple method, we have 2 options in Drupal 8.

https://www.drupal.org/project/simple_sitemap

1. we can add by config page of module like (//localhost//admin/config/search/simplesitemap/custom). There add custom links with priority with change frequency.

2. we can use alter method with simple steps::

a. Create any custom module or write code in any existing custom module.

b. go to custom_module.module file or create new if not exist.

c. write code line with below given example:

Example:

First render class library in file header.

use Drupal\simple_sitemap\Simplesitemap;

/**

 * Use this hook to add arbitrary links to the sitemap.

 *

 * @param array &$arbitrary_links

 */

function finder_simple_sitemap_arbitrary_links_alter(&$arbitrary_links) {


  // Add an arbitrary link.

  $arbitrary_links = array([

    'url' => 'https://localhost/applications',

    'priority' => '0.9',

    'lastmod' => '2020-05-25T14:40:30+02:00',

    'changefreq' => 'daily',

],

[

'url' => 'https://localhost/products',

    'priority' => '0.7',

    'lastmod' => '2020-07-15T13:40:30+02:00',

    'changefreq' => 'daily',

    ],

);

}

Note: We can't add date(lastmod) in custom links by admin, so we have to use alter code for add dates(lastmod) in custom create links.


Note: If have any suggestions or issue regarding 'How to alter or add custom url links in simple sitemap in drupal 8?' then you can ask by comments. 

How to resolve max execution time error in drupal ?

When you found error regarding 'max_execution_time' exceed, then you can follow steps for resolve this error: Steps:   You can put t...