Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using icon code as text is not SEO-optimal #897

Closed
andrey-helldar opened this issue Jan 10, 2019 · 5 comments
Closed

Using icon code as text is not SEO-optimal #897

andrey-helldar opened this issue Jan 10, 2019 · 5 comments

Comments

@andrey-helldar
Copy link

Search engines when indexing the site read all the content. Thus, the code of icons is perceived by them as part of the content, which is harmful to search engine promotion and can be considered by search engines as excessive filling of the site with keywords.

image 1

photo_2019-01-10_17-03-51

image 2

photo_2019-01-10_17-17-58

To solve this problem, use the content property of CSS style:

.material-icons.mi-face:before {
  content: 'face';
}

Thus, both spellings of the code will be correct, but in the second case, the icon will not be taken into account by search engines as content:

<i class="material-icons">face</i>
<i class="material-icons mi-face"></i>

The prefix mi- is chosen because the use of the icon code as classes may conflict with other styles used on the site, and the prefix gives the uniqueness of the class name.

Since the additional styles file occupies 63.7 Kb of space, its connection is not mandatory for those who do not need it.

Example without additional styles:

<link href="material-icons.css" rel="stylesheet">

<i class="material-icons">face</i>
<i class="material-icons mi-face">face</i> <!-- not working -->

Example with additional styles:

<link href="material-icons.css" rel="stylesheet">
<link href="material-icons-content.css" rel="stylesheet">

<i class="material-icons">face</i>
<i class="material-icons mi-face">face</i> <!-- working -->
@denunv
Copy link

denunv commented Apr 12, 2019

How about this?

<i class="material-icons" data-icon="face"></i>
.material-icons::before {
  content: attr(data-icon);
}

@cyberalien
Copy link

You can try Iconify instead of font.

It uses similar syntax, but renders SVG instead of text. Best part is it loads only icons used on page and is available with many other icon sets (FontAwesome, Templarian's MDI, few emoji sets), not just material design icons so you can mix them all on same page without loading massive fonts.

Add this instead of including font:

<script src="https://code.iconify.design/1/1.0.0/iconify.min.js"></script>

Then use code like this for icons:

<span class="iconify" data-icon="ic-face" data-inline="false"></span>

See:

andrey-helldar pushed a commit to andrey-helldar/material-design-icons that referenced this issue Apr 12, 2019
Using:
```html
<i class="material-icons" data-icon="face"></i>
```

Thanks for [@denunv](google#897 (comment))
@andrey-helldar
Copy link
Author

@denunv, thank you!

I'm updated PR #898

@andrey-helldar
Copy link
Author

andrey-helldar commented Apr 12, 2019

@cyberalien,
Does this package upload a JS file to the site and that's it?
Does it not save local copies of icon files?

In the Russian Federation, RosKomNadzor often blocks access to various IP addresses, trying to block access to Telegram. This can cause the inaccessibility of the destination server with icons, so it is extremely important to store them locally on the site.
Package can it?

I think it would be correct to ask a question in the package repository: iconify/iconify#2

@RoelN
Copy link
Collaborator

RoelN commented Feb 3, 2021

It's also possible to use the codepoints directly, e.g. as listed here: https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.codepoints This would work around the ligature text problem. Also @denunv's solution is a good workaround. So I'm closing this issue because I believe it has been addressed. If not, feel free to reopen this issue or create a new one with more information!

@RoelN RoelN closed this as completed Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants