For example, a website that makes music certainly doesn’t want the search engine to include its archive month, because no one will search through it. So we can use JavaScript to output this part of content
The biggest difference between the iNove I’m using and the one I’ve published is that on SEO, you can check the page code. A lot of content in my sidebar is output by JavaScript. Because the sidebar generally plays a role of navigation, but it’s messy and can’t indicate the central content. That’s why Google Adsense often displays “STD ads” in the sidebar
How to use JavaScript to output content? Let’s take the WP recentcomments widget in my sidebar as an example:
General output method:

Copy code

The code is as follows:

<!– recent comments –>
<?php if( function_exists(‘wp_recentcomments’) ) : ?>
<div>
<h3>Recent Comments</h3>
<ul>
<?php wp_recentcomments(‘limit=10&length=17&post=false&smilies=true’); ?>
</ul>
</div>
<?php endif; ?>

JavaScript output method:

Copy code

The code is as follows:

<!– recent comments –>
<?php
//The plug-in is activated to do the following
if( function_exists(‘wp_recentcomments’) ) {
//Glue HTML code line by line
$html = ‘<div>’
. ‘<h3>Recent Comments</h3>’
. ‘<ul>’;
$html .= wp_recentcomments(‘limit=10&length=17&post=false&smilies=true’, false);
$html .= ‘</ul>’
. ‘</div>’;
//Escape processing
$html = str_replace(‘”‘, ‘\”‘, $html);
$html = str_replace(“‘”, “\'”, $html);
//Make HTML as JavaScript output code
$out = ‘<script type=”text/javascript“>’ . “\n”
. ‘/ / <! [CDATA [‘. “\ n” / / XHTML compliant comments start
. ‘document.write(“‘ . $html . ‘”);’ . “\n”
“. ‘/ /]] >'”. \ n “/ / end of XHTML compliant comment
. ‘</script>’;
//Output page code
print($out);
}
?>

In addition, I strongly recommend that recent comments, archives, meta, and ads all be output in JavaScript
Some friends should see that, in fact, my blog seo level is not high, but some things are necessary to do, such as part of the content with JavaScript output, plus nofollow and so on
Is there any sequela? Yes. If someone’s browser doesn’t support JavaScript, then he will not see this part of the content. So this method is available and easy to use, but please be careful