Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Integrating Grav into my current Site - where am I going wrong?

Started by Muut Archive 9 years ago · 3 replies · 1791 views
9 years ago

For the life of me, I cannot get my head around how to integrate Grav into my current static site.

I've built it all in HTML, with a single page layout that links to a couple of other pages. I've read the docs countless times and just do not understand them.

What is the most simple way to get content from one text file into my template (or is it called theme...)?

Has any one got a good in depth guide on how to do this? The Docs just do not cover it - there's too much presumed knowledge in the

9 years ago

Hi Tommy, some time ago I wrote this blog post http://gravcart.com/blog/create-a-grav-site-theme - it shows how I migrated a static HTML template to a Grav theme. I hope it helps clear ideas, I will make an article on the Learn site from it.

Naming conventions: the theme provides Twig templates for pages.
So, as that post says, start by moving all your HTML layout into user/themes/yourtheme/templates/partials/base.html.twig, storing the old content for reference, and gradually add the Grav-specific Twig tags that will allow you to add the CSS and the pages content.

9 years ago

Thanks for the reply - I did indeed find your post and it was by far the most useful I've read so far, so thanks for writing that up. However, it didn't quite go to the depth that I think I need I think my current site fits into a modular page, but I just don't get the reference between everything, there's just so many elements. Pages, blueprints, templates, partials, modular. It's all extremely overwhelming.

From what I understand, partials could be used for reusable content - headers, footers etc. So then I store my main files in the templates folder. Then, what is the simplest what to get a line of text from the pages section, to a certain part of my one page layout?

9 years ago

I think the best way to clear those concepts is to start with an example: the One Page Site Skeleton. You can download it from the site, and install it along with your existing site.

Then start tweaking with the only page that site has, the home page: https://github.com/getgrav/grav-skeleton-onepage-site/tree/develop/pages/01.home - it's a modular page, which means that the page you see is composed by the content found in those 4 modules (basically, sub-pages).

Partials are theme building blocks. For example, all page templates usually extend the partials/base.html.twig template. That template in turn could have a header and footer section defined in a separate partial, for convenience.

Don't worry about blueprints right now - they are useful for letting you customize things inside Admin, but not something you need to know right now.

If you post more details on how you want the page to be structured we can give more ad-hoc hints.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1282 9 years ago
Archive · by Muut Archive, 9 years ago
2 889 9 years ago
Archive · by Muut Archive, 9 years ago
2 4019 9 years ago
Archive · by Muut Archive, 9 years ago
1 2894 9 years ago
Archive · by Muut Archive, 9 years ago
3 1078 9 years ago