Not sure if this will help, but here is my code, just edited a little so that its hopefully not showing anything that my legal team would get me in trouble for displaying. I am sure this code isn't very sophisticated and could be written way better, but this is the best I got from teaching myself this stuff and reusing code from previously build tokens from someone else that is no longer at the company.
#foreach( $o in $sorter.sort(${OpportunityList}, "MarketoCreatedAt:desc") )
#if( $oppFound == 0 && $o.Company_Name__c && $o.Company_Name__c == "Name of Company" )
#set ( $oppFound = 1 )
#if( $o.E_Comm_Link__c == "No E-Comm Link")
https://www.generic-landing-page.com##
## <br>No E-Comm Link##
#elseif( ${lead.Number_of_Opportunities} == 1)
## #set( $b = $o.E_Comm_Link__c.replace("https://", "") )
## $b <br>##
## <a href="$o.E_Comm_Link__c">Click me</a><br>##
$o.E_Comm_Link__c##
## <br>Has E-comm link##
#else
https://www.generic-landing-page.com##
## <br>Greater Than One Opp##
#end
#end
#end
#if ( $oppFound == 0 )
https://www.generic-landing-page.com##
#end
Your code should be refactored more like so:
#set( $interestingCompanyName = "CompanyCo, Inc." )
#set( $defaultLink = "www.example.com/generic-landing-page" )
#set( $EXC_LINK_NO_LINK = "No E-Comm Link" )
#foreach( $o in $sorter.sort( $OpportunityList, "MarketoCreatedAt:desc") )
#if( $o.Company_Name__c.equals($interestingCompanyName) )
#if( !$o.E_Comm_Link__c.equals($EXC_LINK_NO_LINK) && $lead.Number_of_Opportunities.equals(1) )
#set( $outputLink = $o.E_Comm_Link__c )
#end
#break
#end
#end
#set( $outputLink = $display.alt($outputLink, $defaultLink) )
<a href="https://${outputLink}">Click Me</a>
But still, the relevant change is that the entire A is output.
Naturally I'm assuming you don't have any typos in field names and all the fields are checked off in the tree.