LycheeOrg / Lychee-front

JS implementation of Lychee frontend
https://lycheeorg.github.io/
MIT License
48 stars 53 forks source link

[Enhancement] SEO optimization 4/3 - Use `<a>`-tags in a semantical correct way #344

Closed nagmat84 closed 10 months ago

nagmat84 commented 2 years ago

Currently, the Lychee frontend misuses the <a> tag in both directions: it does not use them where <a>-tags should be used and it uses <a>-tags where they should not be used. Moreover the frontend does not set the href attribute correctly. This

  1. causes problems for web crawlers such as search engines, and
  2. has negative impact on the tabbing behaviour (i.e. which elements the browser jumps to when a user presses the tab key).

<a> tags constitute so-called interactive content (see MDN Docs: Content categories - Interactive Content). Interactive content elements should only be used for something the user can click onto (or interact otherwise with it), not for anything else. Moreover, search engines, e.g. Google, only consider <a> tags and there href attribute when they try to find links to other pages (see Google Dev Docs: Understand the JavaScript SEO basics).

Current situation

Currently, Lychee builds a photo element inside an album listing like that (an album element suffers from comparable issues):

<div class="photo" data-album-id="..." data-id="..." draggable="true">
    <span class="thumbimg">
        <img class="lazyloaded" src="..." data-src="..." data-srcset="...">
    </span>
    <div class="overlay">
        <h1 title="...">Overlay Title</h1>
        <a>Overlay subtext</a>
    </div>
    <div class="badges">
        <a class="badge icn-star"><svg class="iconic"><use xlink:href="..." /></svg></a>
        <a class="badge icn-share"><svg class="iconic"><use xlink:href="..." /></svg></a>
        <a class="badge icn-cover"><svg class="iconic"><use xlink:href="..." /></svg></a>
    </div>
</div>

This code uses <a> in four places where it should not be used at all: for the overlay subtext and for the three badges. None of them should is "interactive" or should be clickable by users. The only reason why we use it here is that we also use <a> for the small icons in the toolbar and we want to apply the same style for the icons in the badge.

On the contrary the whole photo is only a <div>, although this indeed represents a link to the photo page.

Intended situation

The frontend should adhere to the following principles: