I am new to Craft and I am basically inheriting a site that I now need to maintain. I am a developer, not really a web designer, and my current task is to change the layout on the homepage. Something simple, I thought.

What I am trying to wrap my head around is the connection between the web content that is defined in Craft and the twig files I see in templates.

So in website content when I look at the Homepage, I see text boxes and other content containers that appear to be where an end user could maintain "changeable" stuff. Going further, I can see in Settings the "Section" for homepage where there is name, handle, template, etc as well as option to "Edit Entry type" where it seems that you don't layout the page as much as define what parts of the page will be editable content. Is that correct?

So "Define Your Field Layout" is a bit of a misnomer? You aren't designing the layout as much as defining what content your "layout" will contain? So that leaves me with: Where do I actually lay out the page? Where is stuff positioned "just so"? I don't see a WYSIWYG tool for that. So, can I assume that the "Entry Template" listed in the section is the twig for the actual layout of the content? In this case, there is 'index' as a value there so I should look for an index.twig that will contain the html and css for the page?

I am just trying to piece together the components. The last piece, if my assumptions above are correct, is that the index.twig, when I find it, will have twig markup that points back to the fields in the "layout" I saw in the section definition?

There just seems to be many moving parts and my past experience with CMS's is if you fail to understand how stuff hangs together then you tend to do too much work to make it work, rather than following convention. As a developer, my first instinct is to write code, which can be a bad approach with a CMS...

Just want to confirm if my understanding of the basic connections is correct..more questions after I start breaking stuff...

Thanks

up vote 1 down vote accepted

Yes, I think what you're saying is completely correct.

Settings > Sections > Homepage > Edit entry type

The "layout" here is only meant for the back end. This is just how you assign fields you want entries in that section to use and what it will look like for admins to create and edit entries.

Settings > Sections > Homepage

Will show you what template is being called when there's a match for that URI.

In the file system, your template files will be located in either /craft/templates if you're using Craft 2, or just templates if your using Craft 3. It's probably worth noting that these directories are usually above the web root.

For example:

.
├── craft
├── templates
└── web <-- web root
    └── index.php

If you're afraid of breaking things on a live site, you could create a duplicate of the site and run it locally or on another server. That's a great way to sandbox changes and play with things to see what effect they have.

Another great way to learn how Craft works is to try out the "Happy Lager" demo site. It's a pretty simple Craft site and well organized. I've see live production sites that are incredibly complex or over-engineered. I can't imagine trying to learn Craft with one of those as my only example.

  • Awesome...connecting all the pieces is the challenge! I do have a "safe" site to edit and break so that will be my next task....thanks so much. – Pete Helgren Oct 10 at 16:17
  • Glad to hear. If this answer helped you out, feel free to up vote it or accept it by clicking the green checkmark. – Alex Roper Oct 10 at 20:53

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.