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

Get content of different pages on Homepage

Started by Ramez 7 years ago · 3 replies · 474 views
7 years ago

I need to create a one-page website but I also need to have every section on the "one-page" as a separate page (for SEO reasons).

e.g.
I've on my Homepage these sections: "Intro, Some info, About, Contact".
I also want the content of these sections to be available on
example.com/about/
example.com/contact/
etc.

I was thinking let's say for the About page, to create a page and extract its content on the homepage. But this seems to have some limitations in styling.

Do you think it's doable or there's a better way in doing it?!

thank you in advance.

7 years ago

I thought about "Modular pages" but it states:

[...] is inherently not a page you can reach directly via a URL. Because of this, all modular pages are by default set as non-routable .

7 years ago

@ramez, Although I'm not a fan of one-page website, I did some playing...

Note: The quote you mention is from the overview of page types. That's only part of the story. There is more information to be found at Modular Pages.

Also of interest is the documentation on Page Collections.

I played with a combination of both above technologies.

The following is based on the One-Page Site skeleton. That skeleton comes with the following pages:

TXT
01.home/
   01._hero/
      hero.md
   02._highlights/
      features.md
   03._callout/
      text.md
   04._features/
      features.md
   modular.md

A modular page is made up by a collection of other pages. In this case the page 01.home/modular.md uses a collection based on its child modular pages.

YAML
content:
    items: @self.modular

However, a collection can also be based on taxonomies. E.g.:

YAML
content:
    items:
        '@taxonomy.tag': features

Reusing the 'features' child modular from 'home' can be achieved as follows:

  1. Add a taxonomy tag to the modular page /01.home/04._features/features.md:
    YAML
    taxonomy:
      tag: features
    
  2. Create a new modular page below /pages/:
    TXT
    02.features/
       modular.md
    
  3. Add the following content to 02.features/modular.md:
    YAML
    content:
       items:
           '@taxonomy.tag': features
    
  4. Point your browser to localhost/my-site/features...

You have now created a new modular page, that uses a collection of pages with taxonomy tag 'features`.

Note: Although this gives you an idea to solve your question about reusing content, I'm not sure if this is the way to go...

Here is some more info on SEO and one-pages websites: Optimizing a single page: One page website SEO

Hope this helps...

👍 1
7 years ago

Whoa! Thank you very much! I'll try to implement it and see how it goes.

I agree on that. Unfortunately I've no saying in this since they sent me a design and I've to just code and implement it in Grav. 🤷‍♂️

From what I can see they did it this way because it's a restaurant website, and they put all the info people are looking for few scrolls away. It's not much content tbh. At the end of the site they have a section that explains every dish... (perhaps that could be moved on a different page).

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 237 2 months ago
Themes & Styling · by Ian, 2 months ago
3 121 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 486 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 75 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 155 3 months ago