Forum Discussion

housikrausi's avatar
7 years ago

Code snippet for noindexing several archive folders

Hi Everybody,

 

i´m working on a archiving strategy for our community at the moment. As descibed in the how to article I have to ad a noindex Tag to the read only archiv named "Test-Archive" board I created.

 

For this I use this code and it works:

<#if coreNode.id == "Test_Archive">
<meta name="robots" content="noindex,follow">
</#if>

 

What should the code look like to use two or more archive folders?

 

I tried this code but unfortunately it doesn´t work:

<#if coreNode.id == "Test_Archive", "Test_Archive2">
<meta name="robots" content="noindex,follow">
</#if>

 

Could someone please help me?

 

Thanks

Marko

  • housikrausi - 

     

    Below is updated code. 

     

    <#if coreNode.id == "Test_Archive" || coreNode.id == "Test_Archive2">
    <meta name="robots" content="noindex,follow">
    </#if> 
  • housikrausi - 

     

    Yes, you can replace my old code with this one. 


    e.g for 12 categories 

    //Assign all the categories id below. 
    <#assign catIDs = ["Test_Archive2","Test_Archive", "Test_Archive3", "Test_Archive4", "and so on.."] /> <#if catIDs?seq_contains(coreNode.id)> <meta name="robots" content="noindex,follow"> </#if>

     

     In above example you just need to update in catIDs variable, the condition will be same. 

12 Replies

  • TariqHussain's avatar
    TariqHussain
    Boss
    7 years ago

    housikrausi-

     

    It is due to you have passed the wrong id inside an array. 

     

    The id of your category is ArchivCallYa and you have passed Archiv_CallYa

     

    Please update the below variable

    <#assign catIDs = ["Test_Archive", "Archiv_CallYa", "Archiv_Mobilfunk"] />

    You can check id of any node by ${coreNode.id}