1

I tried to change page specific meta tag as <meta name="robots" content="noindex"> and also I am having robot tags in pages api. But it's not changed in page still it shows <meta name="robots" content="INDEX, FOLLOW">. Below image for the reference of API returning values:

pages api

Kindly give some suggestions even I have customized the PageMetaResolver. I don't know how to handle this issue.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    Please [DO NOT post images](https://stackoverflow.com/help/how-to-ask) of code, data, error messages, etc. - copy or type the text into the question. – Sandra Rossi Sep 13 '21 at 04:14
  • If you are using Chrome and have Redux, maybe you can check cms page state to see whether `robots` have `["INDEX", "NOFOLLOW"]`. If yes, then the meta should be ``. No need to change the `PageMetaResolver`. – Weizheng Gao Sep 13 '21 at 13:24
  • @WeizhengGao can you share some code as an example? – Front End Developer Sep 13 '21 at 16:53
  • In `OccCmsPageNormalizer`, there is function `normalizeRobots`, which checks pageRobots: (such as: `case Occ.PageRobots.INDEX_NOFOLLOW: robots.push(PageRobotsMeta.INDEX); robots.push(PageRobotsMeta.NOFOLLOW); break;`.) And in `BasePageMetaResolver`, function `resolveRobots()` just returns the Observable of robots which is got from the previous nomalizer. – Weizheng Gao Sep 13 '21 at 17:32

1 Answers1

0

You can provide your own customized normalizer. For example, you can provide a new custom normalizer as explained in here https://sap.github.io/spartacus-docs/connecting-to-other-systems/#providing-custom-converters.

providers: [
    {
      provide: CMS_PAGE_NORMALIZER,
      useClass: YourCustomNormalizer,
      multi: true
    }
  ]

You can copy paste what was done in the source code (OccCmsPageNormalizer), and change what is being pushed in the switch case, such as

   case Occ.PageRobots.INDEX_NOFOLLOW:
          robots.push('noindex'); -- or any of your already created custom enums
          break;

Similarly, you can extend OccCmsPageNormalizer and override normalizeRobots function to change the behavior to your needs

BrianGJ
  • 166
  • 3
  • @BrainGj since I using Spartacus 2.1.7 version and I tried to achieve the custom normalizer its shows a lot of models difference, Error in console – Front End Developer Oct 12 '21 at 16:34