0

I'm building my own theme, and trying to create links to articles this way:

<a href="URL"><img src="THUMB" /><div>TIME_STAMP</div><h3>THE_TITLE</h3></a>

But sometimes Google index my posts with the TIME_STAMP showing before the title in the search results.

What is the best structure/tags/attributes to tell Search Engines to read THE_TITLE as the explicit title of the post and ignore any surrounding text?

3

There are different ways to achieve this. Google tries to automatically extract the publish date of an article you wrote. The most common and easiest way for Google is to use rich snippets: http://schema.org/Article See "datePublished" - property for this.

After you implemented these little HTML-snippets you can test your markup using the Rich Snippet Testing Tool: https://developers.google.com/structured-data/testing-tool/

| improve this answer | |
  • Yes, but what if I want to add any other pseudos before the title not just the date? Say a label such as 'fixed' or 'new', and I don't want to Google to index them. – Ahmed Saad Feb 20 '15 at 11:56
  • 1
    @AhmedSaad You could use absolute positioning on an element much further down in the markup. Or use CSS pseduo :before or :after content. – TheDeadMedic Feb 20 '15 at 12:05
  • 1
    You cannot explicitely exclude parts of your source code to be excluded. Use CSS or your own HTML markup and CSS to separate THE_TITLE from the other elements you will use. I would use a different HTML markup as you showed in your example: <div class="article"> <img class="THUMB" src="path/to/img.jpg" /> <h3> <span class="newBadge"></span> <span class="date">TIME_STAMP</span> <a href="URL" title="THE_TITLE">THE_TITLE</a> </h3> </div><!-- / .article --> </code> I would not put heading-tags as children of an a-tag. – Александр Фишер Feb 20 '15 at 12:45
  • 1
    Ok, so I didn't manage to format the comment nicely, sorry for that. Remove the </code> from it. – Александр Фишер Feb 20 '15 at 12:52

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.