The Little Guy Posted January 29, 2013 Share Posted January 29, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/ Share on other sites More sharing options...
Psycho Posted January 29, 2013 Share Posted January 29, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1408986 Share on other sites More sharing options...
kicken Posted January 29, 2013 Share Posted January 29, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409001 Share on other sites More sharing options...
The Little Guy Posted January 29, 2013 Author Share Posted January 29, 2013 (edited) 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 January 29, 2013 by The Little Guy Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409003 Share on other sites More sharing options...
Psycho Posted January 29, 2013 Share Posted January 29, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409011 Share on other sites More sharing options...
.josh Posted January 30, 2013 Share Posted January 30, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409079 Share on other sites More sharing options...
The Little Guy Posted January 30, 2013 Author Share Posted January 30, 2013 I wrote it in both places, because I submit the data using ajax, then format what was in the text field using JS. I guess I could submit it then wait for php to format it and return that back... Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409158 Share on other sites More sharing options...
KevinM1 Posted February 1, 2013 Share Posted February 1, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409494 Share on other sites More sharing options...
The Little Guy Posted February 1, 2013 Author Share Posted February 1, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/273793-javascript-formatting-and-seo/#findComment-1409547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.