picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Help Topic #610

Closed dawidmachon closed 2 years ago

dawidmachon commented 2 years ago

Hi, again me. @mayamcdougall I created this issue simple to keep all my questions in one place, because there will be a lot but not all on once.

Do you know if it's possible in config setup multiple themes? What I mean: content /blog will use different theme, than content /main for example.

Do you have something in mind for that? Because if there is no such option to manipulate theme per folder or .md file, I will simple setup second subdomain with second pico and use on first one link to redirect.

mayamcdougall commented 2 years ago

It could be handled a few different ways, but none of them are great.

Like you suggested, you could run a separate Pico instance. That would work. (Heck, I even have multiple Pico sites running off the same Pico install with a slight modification and some symlinks. =3)

You could also handle it though using the Template metadata header and some theme doctoring. Template allows you to specify a second twig template to use for that file. You'd have to merge the theme folders together and make whatever changes needed to account for conflicts. Afterward though, you'd effectively have a per-page theme selector.

But that could also be more overhead, since a) you've modified one or multiple themes and b) you'd have to set the Template property on every file you wanted to have a different theme. (So, maybe you'd want the blog to be the default template in this example. Then you'd only have to set Template on the few static pages that aren't a part of the blog).

Alternatively, if your goal isn't to run two entirely separate themes, but just have different page layouts, Template would definitely be better.

Or you could make your own Theme, with some logic that changes layout depending on the page. I'm assuming that's probably a little bit much to start with, but as a Theme developer, I'm usually writing logic to change the layout instead of just using the Template property. 😒

I can help you with however you want to approach it, so let me know. I don't want to overwhelm you with options here. 😅

Edit, Since I never really came back to it: But yeah, setting up a second Pico instance and maybe configuring it as /blog using Nginx would probably be the "easiest" option to just have multiple themes working out-of-the-box.

dawidmachon commented 2 years ago

Thanks a lot for such detailed response. I appreciate your willines to help, but I don't overhelm you with my questions 😅.

I am not using nginx, but Caddy, so for sure later when I will get done with it and make sure my config for Caddy proper working with Pico instance I will drop config here so later somone can use it as reference. Because I have instanced Pico by using two separate containers in Docker on my server - PHP-FPM, Caddy (it's reverse proxy and serving static files).

Additional instance of Pico will be totally not a problem (I am think if can use one PHP container to process different request from two separate containers) - but this is not totally for here, I will check in 'experiment' way 😅

But I am looking for more claver way than additional subdomain. Maybe I will write what I want to achive - I want simple website as a landing page with links to subpages (about, contact form, some my projects, blog, wiki-like page). So for that theme will be 'dark' with fancy buttons, panels and images. But wiki will be tottaly different, I want develop there full page tree for content like side bar. And as last I will try achive blog like page where I will place articles if there will be 'free' time (but probably blog will be empty) 😒

But you know when I start work on this, I want prepare everything. This is why I want to have two themes and tinkering one, later second. And I was thinking if I can hold both templates in one Pico - select in config 'default' one, but in each page put setting which will overide it.

Maybe I messing vocabulary - maybe theme should be one and only messing with layout of page and css on such sub-pages? I am just starting about thinking about it, so this is my loud thinking only. ; )

mayamcdougall commented 2 years ago

Thanks a lot for such detailed response.

It's what I do. Get used to reading. 😉 😅

I appreciate your willines to help, but I don't overhelm you with my questions.

Don't worry, you won't. I'd be happy to go as in-depth as you need. 😁

I am not using nginx, but Caddy... I will drop config here so later somone can use it as reference.

Oh, you mentioned Nginx problems in your other comment, so I just assumed you were still using it. 😂

I've started using Caddy recently too! I was planning to write some Caddy documentation soon to go with it. If you want to leave your config, that's great. Just be sure to censor anything private before you do.

I'm using Caddy in a Docker container as a reverse proxy. My actual Pico server behind it is still Nginx though, so I don't have any experience using Caddy and Pico just yet.

I am just starting about thinking about it, so this is my loud thinking only. ; )

No worries, you've given me some good context. It sounds like you're looking to make something custom for your theme, not necessarily run two existing themes concurrently.

If you plan to build your own custom design for a theme anyway, it would be easy to come up with some logic to switch layouts depending on the page. You could easily have your Twig template check what the ID of the current page is, and change styles based the folder (and, you wouldn't need to write Template: in any of your files).

Maybe I messing vocabulary

Here's a quick overview of what I mean:

So, within your one theme folder (which could be the Default Theme, one you downloaded from the gallery, or your own custom creation), you can have multiple .twig templates (which are HTML layouts), and switch between them by specifying which Template a page should load.

Alternatively, Twig is very powerful and you could code the layout change right in one template. I've never actually used the Template switching myself for anything. I've never really needed it because I'd code different layouts right into index.twig. (Things like switching to a different layout on the front page. Or adding this bit if the page has something specific in its metadata.).

If you're building it from scratch, this would be the route I would take. The Twig code could be as simple as {% if "/wiki" in current_page.id %} or something like that.

And of course it doesn't have to be "from scratch". You could probably easily start with an existing theme from the Themes Gallery and add the necessary bits to it. (Or even combine them, as I said before. 😉).

Are you completely new to Twig? How is your HTML/CSS? What kind of a place are you starting from here?

dawidmachon commented 2 years ago

Are you completely new to Twig? How is your HTML/CSS? What kind of a place are you starting from here?

Fresh in Twig. Html + CSS - I understand a lot what is in code, but dont have a lot experinece writing it by myself. I am more 'idea man', less 'work man ' 😅. But I have some expierience in JS so Twig seems very easy to go. I for sure start adjusting some existing themes for my self. I am not going from scratch, for sure - it's to much for my little time ;P

I will for sure ask there additional things, because Pico seems very funny to use and I am for sure want to have it in my mind. I am bothered only with how long it will be maintanced and what are future plans for it, because community around it seems be 'a little dead'. I saw grav (seems active), Flextype (active, but don't like it docs), Baun (dead too?), Typemill (my next favorite, but not checked, seems very active) - all of them uses Twig as templating. Did you have opportunity to check them?

mayamcdougall commented 2 years ago

I haven't used any of them, but I have checked out the websites for a few of them.

Pico's overall presentation is a little lacking compared to some of the alternatives. They have better themes, documentation, and overall a better new user experience.

These are things that take time, which hasn't been something we've had a lot of (our team is very small, and entirely done in our free time). I'd love to see Pico improve in these regards, and I plan to help it happen where I can. 😁

As far as maintenance goes, I feel fairly confident that Pico will remain maintained for the foreseeable future. That's one reason I feel that "fixing" the PHP 8 issue should be a top priority. It might already be "fixed", but if that fix isn't being shipped out to users, it might as well not be fixed yet!

Future plans though is where it gets a bit more rocky. Pico is pretty much exclusively developed by @PhrozenByte, who's free time has been very limited as of late. Pico is considered to be long-term stable, but any future plans are really more like "wish list" items at the moment.

I'd agree that the community feels "a little dead". There isn't much interest in Pico anymore, especially next to some of the more established solutions. I really feel like Pico still offers something unique with its versatility through simplicity... but that's a hard sell when your time is limited and most alternatives are more approachable to new users.

While Pico certainly isn't dead yet, we're certainly in need of some more community attention and exposure. 😓

Also, for me at least, engagement through GitHub is a big motivator to make some time for Pico. 😉


(I've kind of gone in reverse order to your comment here... 😒)

With your level of experience then, I would definitely consider picking an existing Pico theme that somewhat fits what you're looking for and modify it. Alternatively, if you're okay with diving deeper into the Twig side of things, it's pretty easy to take an existing, static (non-Twig) HTML template (of which the internet has plenty) and modify it to work with Pico.

I hardly ever start "from scratch", but rather like to take existing designs and port them to Pico (like I did with Freelancer). I tend to go above and beyond when I do, but for your own personal use, there's no reason you'd need to make something so fancy.

Have a look at the Default Theme, either in your install or on GitHub. It's a good reference for how to code some of the Pico/Twig basics. If there's another theme that does something you like, look at its source.

Twig is super simple to learn and surprisingly powerful. We don't state this clearly enough in our own Docs, but the Twig Documentation is a really good resource!

If you've got that JS experience, it should be really easy by comparison. 😉

Many of the Themes in our Gallery are MIT licensed, so there's plenty of code to pull some snippets from.

If you start to get an idea for the direction you want to go, let me know and I can try to walk you through it.

"I like this theme, but I wish it did (something from another theme)". Or even "I want this theme for my main site, and this one on my wiki", and I can help you get there. 😁

mayamcdougall commented 2 years ago

You know, I just realized that I did the very thing you're looking for way back in my Notepaper theme.

Click the links under "CSS Pages" in the sidebar. These doesn't change the HTML structure of the page at all, they only grab a separate stylesheet (it's a little hacky). For example, in this case, setting Theme: WritingDesk on a page would apply an extra stylesheet named WritingDesk to it.

But you could easily apply the same methods to, say, change the layout of the elements on the page if you're in a specific folder, etc.

Feel free to look at the source code, but it's really really overcomplicated and out-of-date. I need to rewrite it at some point, and I don't recommend using it for reference. 😅

Just thought it might work as a "visual aid".

dawidmachon commented 2 years ago

@mayamcdougall - I am now solving different issue somewhere else, but I will be back to Pico in next week and take look into your theme. It is very nice!

I am right now investigating Dimension theme - I am already solving a lot of issues there and probably create own repository with it and update this theme to be more modern with pico and create proper documentation for it. Because BesrourMS made amazing work, but I do not like all of his solutions (like nav is not populated automatically from content folder) [I already implemented this]. I will share everything also in upcoming weeks, but right now I am ending another project not related to Pico.

mayamcdougall commented 2 years ago

but I will be back to Pico in next week

No worries. Take your time. The github-actions bot just starts to threaten to close things after they've been stale for a while, lol. I didn't want you to feel like it was anything personal on #609. 😉

Because BesrourMS made amazing work, but I do not like all of his solution

I know exactly what you mean. His ports are pretty good, but they're also a little barebones and/or simple. There are things that I would do differently too. I've actually said before that I'd be interested in redoing them for him at some point (though that wouldn't be any time soon). 😂

He does tend to be active and quick to reply on GitHub. If you revamp some of his work, you could try to see if he's interested in a PR to update the original repo.

If he doesn't care or isn't interested, we could also see about adding a "Forks" section to the theme in our gallery. It hasn't happened yet, but I know eventually I'll have to accommodate forked themes on the website, so I'm not that worried about it.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: