Do I need to wait on "Multisite Grav" or...?

I want to do a total redo of my sprawed-outta-control website and make it more focused. I am considering using subdomains to help my cause:

  • www.my.site – just my regular landing page in a “one pager” style that would lead to the other sections.
  • blog.my.site – my ramblings and musings (currently trying to figure out how to grab these from wordpress and turn them into markdown then move the assets as well. Might be a pointless battle.)
  • pix.my.site – my photos are usually stored on Flickr or Google, so I just need a good place to show them off without the branding.
  • vid.my.site – same as the photos, YouTube unlisted URLS, maybe with JSplayer as a wrapper…
  • status.my.site – something that automatically grabs my tweets, public facebook posts, and instagram
  • about.my.site another one pager where I can pull in linkedIn and about me sections…

Is this possible to do with Grav as it is now and how would I go about pulling something like this off? Coming from wordpress, I could just run Multisite and use different plugins to get the desired effects bu t I want something that I don’t have to worry about – just blog and let a webhook do it’s thing.

I’m very new to this concept so go easy on me, and where possible ELI5 please :slight_smile:

Hi Jason,

and welcome to the Geav community! Your request is possible with the current Grav version. You can read the basic steps in documentation, but I will explain it to you here in detail :slight_smile:

First, it is good if you get a feeling for Grav. Grav is really different from other CMS. Feel free to browse through the different documentation sections. Roughly speaking Grav is based on (text) files in the user directory e.g your complete site is located in the user/pages directory. The settings can be found under user/config. To create a multi-site like you want you first have to create your pages. Assume you create your one-pager in user/pages/01.onepage and your blog under user/pages/02.blog. Then you create two folders user/www.my.site and user/blog.my.site and inside the first one a system.yaml file with the content

pages:
  theme: your-one-page-theme

and inside the second one a user/blog.my.site/system.yaml with content

pages:
  theme: your-blog-the me

where “your-one-page-theme” and “your-blog-theme” are placeholders for your respective themes located in the user/themes folder (here “user/themes/your-one-page-theme” and “user/themes/your-blog-theme”). This is one approach. There exists other e.g. if you want the same theme for both sites but with different site strutures.

Grav also has more sophisticated multisite capabilities via a custom setup.php in the root of the Grav install. This can provide custom locations for various elements, even multiple locations, via PHP streams.

A quick example:

<?php 
use Grav\Common\Filesystem\Folder;

// Get relative path from Grav root.
$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : Folder::getRelativePath($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME']));
$first = Folder::shift($path);
$name = Folder::shift($path);
$folder = "sites/{$name}";
$prefix = "/{$first}/{$name}";

if ($first != 'site' || !$name || !is_dir(__DIR__ . '/' . $folder)) {
    return [];
}

$container['pages']->base($prefix); 

return [
    'environment' => $name,
    'streams' => [
        'schemes' => [
            'site' => [
                'type' => 'ReadOnlyStream',
                'prefixes' => [
                    '' => [$folder],
                ]
            ],
            'config' => [
                'type' => 'ReadOnlyStream',
                'prefixes' => [
                    '' => ['site://config', 'user://config', 'system/config'],
                ]
            ]
        ]
    ]
];

WOW!

This could be the answer to my problems after all in that case. I didn’t realize that it could be that flexible. OK, I will definitely be fooling around a bit more with this in the days to come on the R&D server to see if this will do what I want it to.

One more question-- (OK probably more, but… ;p )
Is it possible to have separate webhooks into the different sections of the site I create? The reason I ask is that I want to use Draftly and Github to compose and version control my posts (I guess until that admin screen is ready.)

I write on the go a lot and from many different devices – from SublimeText to TextWrangler, to MarkView… So this would help me out a lot!

I don’t see why you couldn’t have Draftly and GitHub simiultanous hooks.

We currently have hooks working for bitbucket and github at the same time.

Ok, and now how to redirect traffic to www.my.site and blog.my.site ?

I think you are looking for an .htaccess rule: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

Ok, thanks