Server templating versus Javascript client-side templating - django

I have recently been studying different options (iCanHaz.js + Mustache.js, jQuery templating, Handlebars.js + Mustache.js) to generate the content from the client side. But I am not really sure this is good for SEO.
I am using Django on the Backend
I clearly see the advantages of processing / rendering less HTML on the server BUT, is this solution good for SEO?
Does crawlers read AJAX / Javascript generated HTML?
Thanks

http://code.google.com/p/distal/wiki/FAQ#Do_you_support_search_engine_optimization?

Google crawler read specially marked js|ajax content. But is fact - ajax for seo is bad. JS templating like knockout only for dynamic forms or wizards imho.

Related

Is Django using any front end framework or library?

Is Django Admin validated their data to client side or server side ?
And when we using Django Forms then is still need to use front end framework for data validations ?
It depends, if you use Dajgno-rest-Framework and if you want the front-end Framework to have all those things, then the ideal would be Angular, from version 2 onwards:
Ajax calls: HttpModule or from version 6 HttClient.
It helps you reuse components.
It facilitates the validation of forms (With html5)
Structure code, quite clean.
Animations, if the framework covers it.
Otherwise, django's own template system offers many advantages to work, you can combine using Jquery. If you use Angular Js (Old version) you should be careful with possible conflicts, for example in the interpolation of double braces {{}}.
Yes Django using jQuery library and for custom validations we can use jQuery to validate data.
Here are some links
Add jQuery in django admin site
Adding inlines using of custom jQuery

When to use Angular with Django?

I have a pretty basic question.
Consider a CRUD web application built on Django. You have templates that render data. Those templates might have forms where you submit data to the backend, and that might reload the page to display changes. Sometime, you can make those requests over AJAX, for example when you need to update data on the UI. You can also submit forms with AJAX and update the HTML with it.
On the other hand you have single page applications. You serve a static file, and there is no reload of pages. You have data that comes from an API and populates some front-end template.
What are some guidelines for when to use what? Not in a mutually exclusive way, but within one Django project, what are some reasons/considerations to use a Django template/forms/AJAX approach and when to use Angular?
Thank you.
Something to consider is how "interactive" you want the client-side to be.
I am in the process of converting an existing Django app to use Angular (and django-rest-framework). The app was highly interactive and relied on a lot of custom JQuery to get various widgets working just right. JQuery's constant looping through the DOM made it pretty slow. I am finding that using Angular instead of JQuery is much faster.
So if you have a lot of complexity in the front-end, I would recommend Angular.

effects of using underscorejs templates on SEO

I have a website where I am using underscorejs.
I have many templates(underscorejs) included in the HTML.
there are cases where unnecessary templates are being read on the pages.
Does this effect the SEO rating of my site.
I have heard that Google Search engine reduces the ranking of your site if it finds no Javascript code within <script> tags.
and while specifying underscorejs templates we specify it
<script type="text/template" id="XXX"></script>
PS: I understand that readig unnecessary templates is not good , but this is done from a long time in the site and I dont intend to edit it anytime soon.
The problem I see here is that, since you are using templates that are loaded via Javascript (e.g. Underscore or Handlebars), some search engines will have problems to index your website (although there are techniques to improve indexation).
I imagine that you are building a single-page web application which is rendered in the client side via Javascript using Underscore templates; and I guess you are making AJAX calls to the server to do CRUD operations if needed.
The problem with the SEO in single-page applications is well known. Here is an interesting article (specially interesting if you are using BackboneJs).
Also here is a thread in Stackoverflow dealing with Single-page web applications and SEO.
One more resource: "Making AJAX applications crawlable" from Google.
I hope this helps.

How to prevent Django pages from refreshing after submit?

I am using the Django template system. What I want is, when I submit a form, or click to an url link, page does not refreshes, but loads with the data returning from the server. Is it possible?
I recommend a combination of jQuery (easy, powerful, popular javascript library) and dajax/dajaxice (http://www.dajaxproject.com/). Dajax is very easy to set up and use, and jQuery is also easy to set up and use. Dajax is strictly for AJAX communications through Django. jQuery is perfect for taking a simple site and making it more fluid, intuitive, and user-friendly.
You need JavaScript to do that. What you are looking for is called AJAX (Asynchronous JavaScript and XML). Essentially, it means you use JavaScript to send a request to the server as soon as the link/button is clicked. The server returns some data to your Script, which then can be used to manipulate the HTML page, e.g. by inserting the responded data into the DOM. Since you do everything with JavaScript, no reloading of the whole page is required.
To start, read the AJAX tutorial. There are certain JavaScript libraries that make these things more simple for you (e.g. jQuery), but you really should understand how this stuff works first, since else you might get into trubble while trying to debug it.

Pass array from HTML to Django application

I developed an application in JSPs and Servlets involving drop down menus that kept growing with how many authors per publication their were.
This was done in JavaScript and then in my application iterated through them using a loop. Is this possible using Django? This would be useful in my application.
This link might help you out if you don't want to dive into javascript (too much)
http://www.dajaxproject.com/
Or have a look at this stackoverflow question/awnser:
What is the best AJAX library for Django?
In any case, you need to serialize your array to a JSON string.
Then pass the JSON with an XMLHTTPRequest (ajax) to the server.
Add the javascript tag to your question if you don't mind more JS solutions.
Otherwise look for a Django Ajax framework to do the heavy lifting for you.