Jump to content

JavaScript Formatting and SEO


The Little Guy

Recommended Posts

On my site, I take data from the database and display it directly on the page (without formatting it), if you view the page's source, it looks like this:

 

The sun is nearly a perfect sphere. The mean radius of the sun is 432,450 miles (696,000 kilometers), which makes its diameter about 864,938 miles (1.392 million km). 

It is difficult to get a true feel for how big it is because nothing in our daily life comes even close. But we can use objects that we are familiar with to provide us with a scale that can allow us to at least see how big the Sun is compared to the Earth and the other planets in our solar system.  If you think of the Sun as a basketball, the Earth would only be the size of the head of a pin.

 * If the Sun was hallow, it would take about one million Earths to fill it.
 * The Sun is 110 times wider than the Earth. So 110 Earths would fit across the diameter of the Sun.
 * The mass of the Sun (the amount of stuff) is 330,000 times that of the Earth.
 * The mass of the Sun accounts for 99.86% of the total mass (total amount of stuff) in the solar system.

 

Once the page has loaded, JS then runs over the sections and formats it (bold, lists, blockquotes, italics, etc.).

 

I like doing this, because then I only have to write the formater once in JS, and not twice (Once in JS and once in PHP), but does this hurt with SEO? Also, is there anything else I should think about in doing this, this way?

Link to comment
Share on other sites

I like doing this, because then I only have to write the formater once in JS, and not twice (Once in JS and once in PHP), but does this hurt with SEO? Also, is there anything else I should think about in doing this, this way?

 

????

 

Why are you not just writing the formatting logic in PHP? Doing this in Javascript is, in my opinion, much more difficult and introduces many issues that would not exist if done with PHP. As for SEO, it could affect the results - but whether it hurts the results I can't say. I'm no SEO expert, but I would assume that HTML formatting for heading tags (e.g. <h1>, <h2>, etc.) and other elements would definitely affect how the page is indexed. I just don't see any good reasons to do this with Javascript.

Link to comment
Share on other sites

Google for example does take the HTML into consideration when indexing a site.  For instance, text in <h1> tags will be considered a little more important/relevant than just normal paragraph text.  Another thing is google may not find the URLs to other pages on your site without them being within <a> tags.  I'm not sure whether google will scan the plain text for something that looks like a URL or not.

 

I agree with Psycho though, I see no reason why you would choose to do this with Javascript rather than PHP.  You can control PHP and make it work how you want.  With Javascript you're at the mercy of the end-users browsers / web crawlers and have to work around their limitations.

 

Link to comment
Share on other sites

Okay, But... links will more than likely contain links to outside sources, and Google does have a sitemap of my site plus, it is in my robots.txt file of all the urls.

 

According too Google you should add this to your robots.txt file:

Sitemap: http://mysite.com/sitemap.txt

Edited by The Little Guy
Link to comment
Share on other sites

Okay, But... links will more than likely contain links to outside sources, and Google does have a sitemap of my site plus, it is in my robots.txt file of all the urls.

 

According too Google you should add this to your robots.txt file:

Sitemap: http://mysite.com/sitemap.txt

 

Ok, so Google has a sitemap of your site. And . . . ? As already stated, the "context" of the content of your pages matter. By formatting the content AFTER the page is loaded you are ensuring that any scanning engine will not read the data as you intend for it to be consumed. Thereby making it impossible for appropriate relevance to be given to any data.

 

As for links pointing to external sites - again so what? Google has complicated algorithms for determining page ranking, but one of the key criteria is page links. I'm sure they use the links pointing to a page as well as what that page links to in order to determine the relevance of the page.

 

We've given you several reasons why formatting the page in PHP is the right decision and you only try to defend your current implementation. Why ask a question if you are only interested in validating your own decision instead of getting honest responses?

Link to comment
Share on other sites

I don't understand why you would need to write the formatter in both php AND js to begin with? Whether you decide to do it with php (good idea) or js (bad idea), you should only be having to do it once...can you explain why you think you would need to do it in both places?

 

Anyways, using js to format your data is a bad idea, and it will most certainly hurt your SEO efforts, for all the reasons already given.

Link to comment
Share on other sites

Are you using something like Markdown to mark up your content?

 

In any case, the only time you should use a JS formatter is if you need to see a live preview of what you're writing. Otherwise, like everyone else said, do it on the back end. Semantic markup is paramount in SEO. More important than a sitemap.

Link to comment
Share on other sites

Okay guys, thanks!

 

I am doing a live preview, so I wrote it in JS originally, I then decided to do that for everything, then then you guy convinced me that how I was doing it isn't good, so I then wrote a php version of the formatter as well. It is now being formatted via php when the page loads.

 

Thanks for the input.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.