issue103:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue103:c_c [2015/12/01 12:03] – créée auntiee | issue103:c_c [2015/12/13 12:02] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Last month, I wrote about Ubuntu Phone, intending to follow up on it this month. Unfortunately, | + | **Last month, I wrote about Ubuntu Phone, intending to follow up on it this month. Unfortunately, |
What is static site generation? | What is static site generation? | ||
- | Static site generators are command-line tools that can take content from formats such as markdown and reStructuredText, | + | Static site generators are command-line tools that can take content from formats such as markdown and reStructuredText, |
+ | Le mois dernier j'ai fait un article sur les téléphones Ubuntu avec l' | ||
- | But… why? | + | Qu' |
+ | |||
+ | Un générateur de site statique est un outil en ligne de commande qui accepte des contenus de divers formats, tels que Markdown et reStructuredText, | ||
+ | |||
+ | |||
+ | **But… why? | ||
Anyone who has had to work to optimize a page for performance knows that static sites load much faster (and with less effort), because there is no delay while querying the database, or while running for-loops to insert information. Naturally, some sites lend themselves to content management systems (really large sites, sites with various editors and moderators, or sites that need to serve dynamic content). As is always the case in web design, it’s a matter of picking the right tool for the job, in order to create the site as fast as possible, to have it perform well, and to avoid reinventing the wheel at every turn. | Anyone who has had to work to optimize a page for performance knows that static sites load much faster (and with less effort), because there is no delay while querying the database, or while running for-loops to insert information. Naturally, some sites lend themselves to content management systems (really large sites, sites with various editors and moderators, or sites that need to serve dynamic content). As is always the case in web design, it’s a matter of picking the right tool for the job, in order to create the site as fast as possible, to have it perform well, and to avoid reinventing the wheel at every turn. | ||
Ligne 16: | Ligne 22: | ||
A comparison | A comparison | ||
- | Note: According to studies by Google, any site that takes longer than 1 second to load (on mobile, mainly) will generally have users leave due to the wait. Studies from Amazon and Google also saw that an increase of loading time of 1 second (say, for example, from 400ms to 1.4s) could result in a drop of revenue between 14 and 18%. | + | Note: According to studies by Google, any site that takes longer than 1 second to load (on mobile, mainly) will generally have users leave due to the wait. Studies from Amazon and Google also saw that an increase of loading time of 1 second (say, for example, from 400ms to 1.4s) could result in a drop of revenue between 14 and 18%.** |
- | A site I am working on was originally created using Django CMS - where it would load in about 612ms from my local machine (with no network latency, a quad core CPU, and an SSD), which is perfectly reasonable. Shifting it to an Nginx server running uwsgi saw the load times jump up to 700-800ms. However, the more content that was added to the page, the longer it would take. Version 3.2 of Django CMS seems to have improved on the speed, but it is not, as of writing, at a final release. The equivalent site using Pelican (a static site generator) loads in 402ms, and the only optimization I have done so far is to merge my CSS files. There is no compression of any sort running, and is being served only with python http.server. As the site is a redesign for my own company, and I will be the only one managing it, I have no need for a CMS – I could just as easily write the HTML by hand. However, the number of pages make it unreasonable to create everything by hand, which is where Pelican comes in. I can manage my content easily in reStructuredText (or, theoretically, | + | Mais... pourquoi ? |
- | I’m sold! Where do I start? | + | Toute personne qui a eu à travailler à l' |
+ | |||
+ | Mais mon site CMS se charge rapidement ? | ||
+ | |||
+ | Il est possible d' | ||
+ | |||
+ | Une comparaison | ||
+ | |||
+ | Note : Selon des études faites par Google, tout site dont le chargement prend plus d'une seconde (principalement sur les téléphones mobiles), découragera les utilisateurs du fait de l' | ||
+ | |||
+ | **A site I am working on was originally created using Django CMS - where it would load in about 612ms from my local machine (with no network latency, a quad core CPU, and an SSD), which is perfectly reasonable. Shifting it to an Nginx server running uwsgi saw the load times jump up to 700-800ms. However, the more content that was added to the page, the longer it would take. Version 3.2 of Django CMS seems to have improved on the speed, but it is not, as of writing, at a final release. The equivalent site using Pelican (a static site generator) loads in 402ms, and the only optimization I have done so far is to merge my CSS files. There is no compression of any sort running, and is being served only with python http.server. As the site is a redesign for my own company, and I will be the only one managing it, I have no need for a CMS – I could just as easily write the HTML by hand. However, the number of pages make it unreasonable to create everything by hand, which is where Pelican comes in. I can manage my content easily in reStructuredText (or, theoretically, | ||
+ | |||
+ | Le site sur lequel je travaille actuellement a été créé à l'aide du CMS Django, à partir duquel il se charge localement en plus ou moins 612 ms (sans latence réseau, un CPU quatre cœurs et un SSD) ce qui est tout à fait acceptable. En passant sur un serveur Nginx [Ndt : serveur à hautes performances] tournant sous uWSGI [Ndt : conteneur d' | ||
+ | |||
+ | **I’m sold! Where do I start? | ||
There are various static site generators on offer. The most common and well-known is Jekyll, which is used for GitHub Pages, among other things. Jekyll uses the Liquid templating language, and is written in Ruby. I, however, am currently using Pelican, and for two main reasons: | There are various static site generators on offer. The most common and well-known is Jekyll, which is used for GitHub Pages, among other things. Jekyll uses the Liquid templating language, and is written in Ruby. I, however, am currently using Pelican, and for two main reasons: | ||
Ligne 26: | Ligne 46: | ||
It is written in Python, and so has integrated translation options for multilingual sites (using Jinja2 i18n). As my site is always in English and German, this was a big factor for me. | It is written in Python, and so has integrated translation options for multilingual sites (using Jinja2 i18n). As my site is always in English and German, this was a big factor for me. | ||
- | So, depending on what you’re most comfortable with, you may prefer Jekyll over Pelican, or a number of other static site generators over either. Use what you’re comfortable with, as it will help cut down the learning curve. If you want to use plugins for automatic integration of bootstrap (for example), then I would recommend checking the plugin options before choosing a generator. | + | So, depending on what you’re most comfortable with, you may prefer Jekyll over Pelican, or a number of other static site generators over either. Use what you’re comfortable with, as it will help cut down the learning curve. If you want to use plugins for automatic integration of bootstrap (for example), then I would recommend checking the plugin options before choosing a generator.** |
- | Does this mean I can’t use forms, or any dynamic content at all? | + | Vendu ! Par où dois-je commencer ? |
+ | |||
+ | Il existe différents générateurs de sites statiques. Le plus diffusé et le plus connu est Jekyll, utilisé notamment pour les pages GitHub. Jekyll utilise le langage de trame (templating) Liquid qui est écrit en Ruby. Néanmoins j' | ||
+ | |||
+ | Il utilise Jinja2 pour les trames, le même langage que Django. Ce qui signifie que je peux importer rapidement des trames existantes. | ||
+ | |||
+ | Il est écrit en Python et a, de ce fait, des options de traduction intégrées pour les sites multilingues (en utilisant Jinja2 i18n). Comme mon site est toujours à la fois en anglais et en allemand, cela compte beaucoup pour moi. | ||
+ | |||
+ | Donc, en fonction de ce qui vous convient le mieux, vous choisirez plutôt Jekyll que Pelican ou l'un des nombreux autres générateurs de sites statiques. Choisissez celui qui vous va le mieux, car cela réduira le temps d' | ||
+ | |||
+ | **Does this mean I can’t use forms, or any dynamic content at all? | ||
Forms are essentially just HTML that gets sent via POST (typically) to a php file. If you use a combination of Nginx and apache (or just apache), you can still include a php file for sending the information around. Depending on what you mean by dynamic content, it should be possible too. iFrames or widgets from other sites shouldn’t be an issue, or, if you want to semi-dynamically create a grid (for example), you can create templates using for-loops to iterate through information in order to insert it into HTML. If you’re looking for login areas and personalized HTML, a CMS will probably be easier for this. | Forms are essentially just HTML that gets sent via POST (typically) to a php file. If you use a combination of Nginx and apache (or just apache), you can still include a php file for sending the information around. Depending on what you mean by dynamic content, it should be possible too. iFrames or widgets from other sites shouldn’t be an issue, or, if you want to semi-dynamically create a grid (for example), you can create templates using for-loops to iterate through information in order to insert it into HTML. If you’re looking for login areas and personalized HTML, a CMS will probably be easier for this. | ||
Ligne 34: | Ligne 64: | ||
Okay, I’ve installed a generator. What now? | Okay, I’ve installed a generator. What now? | ||
- | Now would be the time to check the homepage and view the documentation. As each generator has a slightly different file structure, and different commands to compile, it’s necessary to check the documentation. Once you’ve created a project (most likely done with a quickstart command), then it’s time to create some sample content, and a template (or to adjust an existing template). | + | Now would be the time to check the homepage and view the documentation. As each generator has a slightly different file structure, and different commands to compile, it’s necessary to check the documentation. Once you’ve created a project (most likely done with a quickstart command), then it’s time to create some sample content, and a template (or to adjust an existing template).** |
- | My site is done...do I have to buy hosting? | + | Cela signifie-t-il que je ne peux point utiliser de masque de saisie ou de contenu dynamique ? |
+ | |||
+ | Les masques sont constitués essentiellement de HTML envoyé par POST (habituellement) vers un fichier php. Si vous utilisez une combinaison de Nginx et Apache (ou simplement Apache), vous pouvez toujours inclure un fichier php pour transmettre les données. En fonction de ce que vous entendez par fichier dynamique, ce devrait être également possible. Les iFrames ou les widgets d' | ||
+ | |||
+ | Bien, j'ai installé un générateur. Et maintenant ? | ||
+ | |||
+ | Maintenant il va falloir mettre au point la page d' | ||
+ | |||
+ | **My site is done...do I have to buy hosting? | ||
Since static HTML is so easily served, there are some offerings where you can upload a site without much trouble. For example, GitHub Pages. Technically, | Since static HTML is so easily served, there are some offerings where you can upload a site without much trouble. For example, GitHub Pages. Technically, | ||
Ligne 44: | Ligne 82: | ||
Depending on how quickly your site loads, you may not feel you need to. My recommendation, | Depending on how quickly your site loads, you may not feel you need to. My recommendation, | ||
- | I hope this article has been interesting for anyone looking at, or working on, a project where you keep thinking “this site is almost too small for a CMS, but too large for doing it by hand!”. Or anyone interested in creating a quick project website for GitHub. If you have questions, suggestions, | + | I hope this article has been interesting for anyone looking at, or working on, a project where you keep thinking “this site is almost too small for a CMS, but too large for doing it by hand!”. Or anyone interested in creating a quick project website for GitHub. If you have questions, suggestions, |
- | Further Reading | + | Mon site est terminé... Dois-je acheter un hébergement ? |
+ | |||
+ | Puisque le HTML statique est très facilement géré, vous trouverez quelques endroits où l'on peut charger un site sans trop de problèmes. Les GitHub Pages par exemple. Techniquement, | ||
+ | |||
+ | Dois-je optimiser ? | ||
+ | |||
+ | Selon la vitesse à laquelle votre site se charge, vous pourriez n'en avoir pas besoin. Ma recommandation néanmoins serait d’optimiser les images et d' | ||
+ | |||
+ | J' | ||
+ | |||
+ | **Further Reading | ||
Jekyll homepage: https:// | Jekyll homepage: https:// | ||
- | Pelican: https:// | + | Pelican: https:// |
+ | |||
+ | Pour aller plus loin | ||
+ | |||
+ | La page de Jekyll : https:// | ||
+ | |||
+ | Celle de Pelican : https:// |
issue103/c_c.1448967830.txt.gz · Dernière modification : 2015/12/01 12:03 de auntiee