Exploring version control and Git workflows in block themes (Site Editor) #59480
Replies: 11 comments 3 replies
-
This is not directly related to version control, but I do think more work around user management in the Site Editor could alleviate some of the challenges developers face. I recently opened a few issues about improving how user capabilities are handled in the Site Editor. I could also see a whole set of new capabilities specifically created for Site Editor interactions. (#56299, #56300) For example, what if you could prevent specific users from editing theme templates entirely? They could create new ones, but the theme templates are locked (and presumably under version control). |
Beta Was this translation helpful? Give feedback.
-
Here's a link to a blog post (Thoughts on Version Control for Block Themes) I wrote about this a while back, which has some comments from community members as well. I summarized the big picture in a comment reply which I'll quote here:
The best tool currently is Create Block Theme, but the main issues are
I'll also note that Pattern Manager was another tool in this arsenal, but that repo is officially archived. |
Beta Was this translation helpful? Give feedback.
-
Thanks for creating this discussion! I think that #59272 may have a large potential to improve some of these flows. |
Beta Was this translation helpful? Give feedback.
-
Great discussion to have! One thing that's common on sites I build: Archive pages (be it for posts or custom post types) often have some content before and after the query loop. For example before there may be a title, some text and after the posts there may be some banners like featured posts, featured categories, a contact banner, ... Now I want editors/users to change the content around the query loop, but of course not the layout of the template or the query loop itself. I could create a template, lock every block in it - except the parts that the user can modify (e.g. set them to contentOnly locking, so they can't remove them). But that means, even if the user wants to change something, they have to enter the site editor and edit the template. Typically, I don't give users/editors access to the site editor, since these are highly custom themes and I also don't want to explain to them the whole concept of the site editor (because that may be a burden on them). But also, as soon as the user would change some text, the template is stored in the database and I can't update it in the theme files / version control anymore - or actually I can, but it doesn't change/update the template. But what I do now, mostly, is creating "fake" archives by creating a page called "blog" or "events" with locking set up. The user can edit the page like any other page. But of course, I can't change the query loop / template from the file system/version control. Just wanted to share how I approach that problem. In the end, it often boils down to changing posts/pages by hand or writing migration-scripts in PHP which update post_content. |
Beta Was this translation helpful? Give feedback.
-
I hope I’m not breaking any rules by sharing a link to Shopify’s approach to this problem 🫣 I haven’t done any digging into the specifics, so not sure if there’s anything that could be relevant to WordPress. I can say that their GitHub integration was a game changer, and made my life as a theme developer much easier. |
Beta Was this translation helpful? Give feedback.
-
I've had to just resort to always remind myself to make changes in the GUI site editor and then export but I'd love an alternative. |
Beta Was this translation helpful? Give feedback.
-
Hope it's ok to post this link here. I wrote a litte bit about our current approach to developing block themes, versioning and the pain points and adjustments we made to our workflow: |
Beta Was this translation helpful? Give feedback.
-
Another thing I think to overcome in this area is bi-directional editing (Site Editor and code editor) of Patterns IF you have PHP in them. If code editor created patterns were allowed to be edited and exported for git purposes this wouldn't work right now I believe. Adding Patterns via code is great so that you can have version control, but if you have PHP in your pattern (so image URLs work across domains, so the date is added dynamically, etc.), then the Site Editor will reject this code when you try to edit it (by copying and pasting in your pattern code). This is currently a pain point because it's much easier and faster to edit block code in the Site Editor than by hand. |
Beta Was this translation helpful? Give feedback.
-
There isn't much documentation on how using Git can help with block development, either. Not sure if Git is even much mentioned anywhere in the end-user or developer docs AFAIK. This information could have a lot of crossover value in the Theme, Plugin, and Block Development handbooks. I've been working on a notebook full of starting points, best practices, etiquette, and simple "How To's" that is an ongoing WIP. The goal was to share this on the DevHub (developer.wordpress.org) for people who want to build blocks but don't have much experience with version control. Thinking about all the folks who are coming out of React code bootcamps and such, that could be a great asset to the WordPress Community. +1 agree @ndiego! Having finally gotten version control mostly under my belt, it's saved a lot of time and heartache. |
Beta Was this translation helpful? Give feedback.
-
It looks like wordpress.com has launched github deployments, looks really good, if anything good example for .org. |
Beta Was this translation helpful? Give feedback.
-
So happy to see this crucial topic being discussed! I'm a web designer on a Mac. This is my work-around: Custom CSS
Theme Templates, Patterns, and Global Styles
Github repo
|
Beta Was this translation helpful? Give feedback.
-
This is an open discussion about how developers can approach using block themes, and specifically the Site Editor, if their workflows/projects require templates (and perhaps even content) to be version-controlled.
The Site Editor can get tricky. We want users to be able to use the Site Editor to make modifications to their site easily. But as soon as they do so, any version-controlled templates are overridden.
Version control and Git workflows have been a common discussion point, and it recently came up in the Hallway Hangout on overlapping problems in the Site Editor, which continued in WordPress Slack.
I know this has been a challenge that the Meta team (cc @ryelle, @adamwoodnz, @StevenDufresne, @renintw) has been tackling with WordPress.org when converting large sections of the site to block themes.
If you have a current process you are using, please share. If you have ideas on how WordPress could be improved to better support these types of workflows, share that as well. Let's get the ideas flowing! 💪
Beta Was this translation helpful? Give feedback.
All reactions