0

On most posts on my website the date is displayed. There are however some posts where I would not like to show the date.

Would it be better to use display:none; via css or actually remove the code for the date altogether.

Here is an example of the code I use (generated by a php function)

<span class="posted-on">Posted on <time class="entry-date published" datetime="2014-07-21T18:15:52+00:00">July 21, 2014</time><time class="updated" datetime="2014-07-21T18:17:35+00:00">July 21, 2014</time></span>

The reason I ask is that I was under the impression, even if I don't want to display the date, that the timestamp would be useful to search engines.

Currently I use display:none; when I don't want to show the date.

  • What do you mean by "useful to search engines"? Are you trying to control how frequently your pages are crawled, have a date appear with you listings in the search results, or aiming to improve your rankings? – Stephen Ostermiller Oct 6 '14 at 16:52
  • Basically some pages I dont want users to really see the date as it isn't useful to them but I assumed the publish and updated dates are always useful to search engines. I just don't want to hurt my rankings. – stemie Oct 7 '14 at 6:49
  • Removing the dates entirely from your pages will in no way hurt your rankings. – Stephen Ostermiller Oct 7 '14 at 8:13
2

Don't show content only to search engines and not to users. This is called cloaking is a violation of the search engines terms of service.

If this content is never going to be seen by users then you should remove it from the HTML completely.

  • I was aware of cloaking but for some reason thought this might be useful but thanks for the clarity. This general rule is one I will remember! – stemie Oct 6 '14 at 15:02
  • You could always use a clock icon or something similar that when clicked or hovered over it reveals the time of publish. Display:none can be used but not for hiding information from Google or Users without some kind of trigger. This can be achieved by using CSS .the-time{display:none;} .the-icon-time:hover .the-time{display:block} or by using a JavaScript method but ensure you use some kind of fallback using no-js class. – Simon Hayter Oct 6 '14 at 16:05
2

Hidden content is fine as long as you have a way of accessing that information...

To extend on Johns answer you can hide content from both users and search engines if the content can be viewed by a action. What this means is any content that is hidden must have a way of being viewed by both users and search engines.

Ideal CSS Method

This can be done in pure CSS without the need for JavaScript unless you need an additional feature such as show for X time then hide.

HTML CSS display:none method

A valid CSS method would be to use a display:none method with a hover over trigger like so:

<div class="time-icon">
    <time class="time-data" datetime="2011-10-05T09:00Z">9am on October 5</time>
</div>

.time-data {display:none;}
.time-icon:hover .time-data{display:inline-block;}

You could even make the time viewable when they hover over the title of the page rather than a icon, for example:

.time-data{display:none;}
h1:hover .time-data{display:block;}

HTML CSS opacity method

Some people prefer to use opacity but bare in mind some older browsers may not support this feature and may just display the element, HTML and CSS would be the same apart from these elements:

.time-data{-webkit-opacity:0;-moz-opacity:0;opacity:0;-webkit-transition:all 2s ease;-moz-transition:all 2s ease;-ms-transition:all 2s ease;-o-transition:all 2s ease;  transition:all 3s ease;}
.time-icon:hover .time-data{opacity:0.75;}

A example of this I made on JSFiddle.

  • 1
    Interesting workaround! – John Conde Oct 6 '14 at 17:46
  • The function I use outputs published and updated dates, showing both of them seems like overkill for the user but surely not for the search engines. Is it really bad if I show the one and hide the other. I understanding the cloaking issue but this isn't anything malicious. My client certainly won't let me display both (using a hover element or otherwise). I mean am I likely to get punished that badly? – stemie Oct 7 '14 at 7:17
  • Cloaking is anything that is hidden that can't be viewed in anyway, doesn't matter what it is. – Simon Hayter Oct 7 '14 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.