Set up the product details layout |
At this point, if we were to view the product in the browser it would be a blank page. The Markdown file only has metadata: stuff in the `---` which doesn’t render naturally.
To make something render for our product, we need to create and define a layout.
|
label |
type |
ecommerce-pattern-library |
folder |
|
label |
type |
indent |
_layouts |
folder |
1 |
|
label |
indent |
fade |
default.html |
2 |
true |
|
label |
indent |
product.html |
2 |
|
label |
type |
indent |
fade |
_products |
folder |
1 |
true |
|
label |
indent |
fade |
24-carat-diamond.md |
2 |
true |
|
|
|
Make a brand new layout, called `product.html`.
We are going to explore the idea of nested layouts. Layouts, that use other layouts.
- We created a new layout specifically for products because we want those pages to all look the same—but different from other pages on the website.
- But, we still want to share the header & footer from within default.
|
html |
_layouts/product.html |
---
layout: default
---
<h1>{{page.name}}</h1>
<p>{{page.description}}</p>
<img src="{{page.image}}" alt="">
|
num |
text |
2 |
Tell Jekyll that our `product` layout should still inherit the `default` layout, getting our header & footer.
|
|
num |
text |
5 |
I’m putting just a simple `<h1>` on this page for now, it’s outputting the name from our Markdown file.
|
|
num |
text |
6 |
We’ll do the same thing again to output the description for our product.
|
|
num |
text |
7 |
The image isn’t too terribly different, just the placeholder variable is being inserted into the images’ `src` attribute.
|
|
|
**We’re not going to finalize the product details page yet—that will happen later in the term.**
Still can’t quite see anything in the browser…
|