6
Recently I came across this theme, more precisely the tool Hugo, that basically builds sites from themes and Apis reminding a lot of Ruby on Rails.
I ran a test on build of an application that uses a static JSON for content listing, example:
products.json
[{
"id": "1",
"name": "Klingon dictionary",
"price": 34.87,
"image": "/images/dictionary.jpg",
"description": "nIvbogh tlhIngan dictionary qaStaHvIS veng SuvwI'",
"url": "http://snipcart-hugo.netlify.com"
}, {
"id": "2",
"name": "Captain Kirk Phaser",
"description": "The Original Series Phaser comprises a small, hand-held Type I Phaser, which slots into a larger Type II Phaser body with a removable pistol-grip.",
"price": 145.98,
"image": "/images/phaser.png",
"url": "http://snipcart-hugo.netlify.com"
}]
HTML
<div class="col s6">
<h2 class="header">{{ .name }}</h2>
<div class="card horizontal">
<div class="card-image">
<img src="{{ .image }}">
</div>
<div class="card-stacked">
<div class="card-content">
<p>{{ .description }}</p>
</div>
<div class="card-action">
<button
class="snipcart-add-item waves-effect waves-light btn"
data-item-id="{{ .id }}"
data-item-name="{{ .name }}"
data-item-price="{{ .price }}"
data-item-url="{{ .url }}">
<i class="material-icons right">shopping_cart</i>
Add to cart
</button>
</div>
</div>
</div>
</div>
When consulting the requests, the file products.json
was not requested in client
making clear the safety of working with JSON directly on DOM
.
What is and how this kind of tool works?
It is a very cool thing, has several similar tools each with its characteristics. Many sites don’t need to be dynamic, they just need a generation structure. Why generate a page for each request if it "never" changes? Then you take the data from somewhere, a database, file, etc. and generate the static HTML and serve it performatively. Simple and efficient. Pity that many people do not see these things, just follow formulas. I’m making a blog that will work like this.
– Maniero
Very interesting this new look for web, when it is ready the blog link here :), by the way I think better answer the question, because hardly anyone will do it.
– Felipe Duarte