I'm trying to set some Simple Sitemap settings programmatically. I'm using the following to set whether or not a specific node is indexed:

\Drupal::service('simple_sitemap.generator')->setEntityInstanceSettings('node', $node->get('nid')->value, ['index' => FALSE]);

This works fine and I was able to see the results reflected in my sitemap. However, this is only reflected in the "Simple Sitemap" form of that node if the value is set to TRUE. If FALSE neither radio button is selected.

This is confusing to others who are editing the site. How can I get this reflected in the form?

Empty form

2 Answers 2


I figured this out, but in case anyone else runs into this. The documentation in the readme.md file shows the following format the settings:

setBundleSettings('node', 'page', ['index' => TRUE, 'priority' = 0.5])

Instead of using TRUE/FALSE I changed the index setting to 0/1 and this was successfully reflected in the form as expected.

\Drupal::service('simple_sitemap.generator')->setEntityInstanceSettings('node', $node->get('nid')->value, ['index' => 0]);

  • In case people have trouble with this, the service has since been updated and is now simple_sitemap.entity_manager. So the result would be instead: \Drupal::service('simple_sitemap.entity_manager')->setEntityInstanceSettings('node', $node->get('nid')->value, ['index' => 0]);
    – Ron
    Commented Sep 6, 2023 at 18:40

I have created an issue for you on drupal.org and fixed it. Please use the boolean values when using the API instead of the integers.

The fix along with many other improvements can be found in branch 3.x.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.