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. 

  • housikrausi - 

    Below condition will work for two categories. 

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

    • housikrausi's avatar
      housikrausi
      Expert

      TariqHussain

      Thank you for your help and snippet. Unfortunately I got an error message by using the code:

      Do you have any idea what have might gone wrong?

       

      • TariqHussain's avatar
        TariqHussain
        Boss

        housikrausi - 

         

        Below is updated code. 

         

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