Creating project shortcuts [i dont know the correct terms]


#1

howdy folks,

long time minimal user of jekyll. first time posting & im an addict…
wait, wrong room

so im currently working on a new jekyll site that im converting from a html template ive built up & something thats been on my mind is creating a project includes. i dont know the correct terms since i just mash things together like i would mashed potato & hope for the best it tastes nice.

but my thought process of what i want is like this.
i will have a includes file called project.html. this would hold a minimal amount of code, but would have something like this

//these are the div containers im trying to use
<div class="col-sm-12">

	{project image stuff & link}
	<div class="card-container card-container-lg">
    <h4>{PROJECT TITLE}</h4>
    <p>{small description}</p>
  {project link button}
  </div>

//these are the div containers im trying to use
</div>

its using those 2 div to create a kind of modular way to make projects on page, with me able to change the size of the project image depending on how important it is.
then in my say index.html i will then use a if statement as such

{% if site.project %}
    project content
{% end %}

is this the right way on going at things?
im not 100% sure plus its hard reading content online for it since i have a hard time reading content in general. tried finding things but im guessing my wording is completely off.
but just wanted to reach out & ask for help regarding this

thanks


#2

also im not using any plugins & dont want to use plugins. im trying to keep things as vanilla as possible. plus its one way to learn stuff much further :wink:


#3

this obviously would apply to many things. such as text box or links etc. :wink:


#4

you can and should do stuff like that when it makes sense.

Most of the time I use a data file rather than the config file as it is easier to keep it clean. I only use the config file for simple things. The usage is fairly similar.

Assuming there will be more than one project, you will need to understand how to nest items in YAML properly - its not hard just unforgiving if your syntax is not correct.

If you are not familiar with iterating over data this is an excellent resource:

After you are the master of that type of thing you can look at how to do it with an include and how to pass things in with the include.

I use data files for all kinds of things:

  • product lists/galleries
  • image galleries
  • faqs
  • anything else that has repeated html