I have an <a> element that may or may not have an href attribute.
If this element doesn't have an href element, I get the following error from google.
Links are not crawlable.
Do we have a way to change the type of an <a> element and tell to the bot that this isn't a link anymore ?
<a [href]="url">{{ text }}</a>
Or is as follow the only way
<a *ngIf="url" [href]="url">{{ text }}</a>
<p *ngIf="!url">{{ text }}</p>
The best would be an angular solution, but any javascript is welcome.
As @cloned mentioned, this the a-element need to have an href.
Here's how I have deal with a more complex angular example, since I wanted to change the type of the a-element to avoid copying myself.
<a
*ngIf="attributes?.url"
[href]="attributes.url"
>
<ng-container *ngTemplateOutlet="customContent"></ng-container>
</a>
<div *ngIf="!attributes?.url">
<ng-container *ngTemplateOutlet="customContent"></ng-container>
</div>
<ng-template #customContent>
<!-- The lot of content my element needed to be inside -->
</ng-template>