I recently started learning to build webpages and custom themes with Wordpress using Timber, twig and Advanced Custom Fields and I don't really know how to organize everything. So far I've been tinkering with everything in the same place (.php and .twig separated) but I can really see that becoming a mess.
What is a recommended folder and file structure to use when working with Timber?
1.3k views Asked by Juan Antonio Rodríguez Gabriel At
1
There are 1 answers
Related Questions in WORDPRESS-THEMING
- wordpress delete unwanted location
- What wordpress plugin prevent sharing of contact information amongst users?
- how to make a porfolio carousil like this in wordpress?
- Woocommerce place order in the product page
- How to fix the error, that is caused by updating elementor?
- Location of the current theme json file for WordPress Site Editor so I can add custom font?
- If and Else in single.php for showcasing multiple categories
- WordPress site not translating after adding .mo and .po files to the theme's lang directory
- How do you change the appearance of a set theme in wordpress? How do you edit the code of the theme to change asterick to a different image?
- Wordpress 6.4 Lock editing on all template files
- White space on the left and down of wordpress theme
- Not able to build menus in Wordpress
- Headless WP theme with NextJS
- Avada theme not appearing functions in functions.php file for woocommerce
- Custom Plugin: WordPress Frontend Edit Cannot Update
Related Questions in WORKFLOW
- Github action Post Run fails workflow
- Github actions set environment on a top level in workflow
- GHA reusable workflow succeeds with workflow_dispatch client but fails with push client
- Failed to create ISE, as i want to use this enable netorking in Logic app
- Post processing queue for Slurm
- Process level view on Flowable
- How to enable a PR originating from a forked repo to cause a GitHub workflow to push to a branch (gh-pages) in the original repo?
- not able to add previous commit into github tag using workflow
- Workflow for quickly building something with a specific non-standard build option
- Extract current running stage from dvc
- 'Workflow' cloud not be added to Xcode Cloud, request is rated limited/you must have 'Admin' permission
- Github action not getting triggered on scheduled time
- Flows sending out emails
- How to cancel a run for a non-existent runs-on member in github workflows?
- Github basic issue automation
Related Questions in TIMBER
- Filtering posts within a page that displays a single category php
- Issue update menu title link to page with an apostrophe in WordPress with Timber
- How to add new custom page in Timber Wordpress
- Timber resize(width, height) filter is stretching images instead of cropping, when crop is 'default'
- Is there a quick way in Timber/Twig to convert images to pull from CDN?
- Need to change Advanced custom Fields image to a gallery - Timber/Twig
- Can't locate block template
- Timber upgrade 1.19 site.language deprecated?
- Timber /towebp - some thumbnails not generating properly (half grey)
- Timber wordpress - include with varriables
- How to implement the "blog functionality" in WP using Timber and Twig?
- Why does this ACF field not update properly?
- WordPress Timber/Twig: Failed to load Twig template, cache might be corrupted fatal error when upgrading to PHP 7.4.x
- Timber v2 Issue
- Use the same permalink structure for multiple taxonomies
Related Questions in DIRECTORY-STRUCTURE
- VS Code - stacked folders - Set stacked folder structure back to default?
- example of how to separate sample project into separate files?
- How to get parent directory of classpath inside @PropertySource()
- How To share/manage Typescript Types between Frontend and Backend In Big Projects
- How To share Typescript Types between Frontend and Backend In Big Projects
- Problem in creating folder and file after upload in Django
- Filtering and copying with preserving folder structure
- R - how to get a multi-level list using list.files
- Incorrect Numbering of WebP Files in Directory Traverse Script
- Ruby Script Recursively Creates Deeply Nested Directories
- Batch Script to Create Multiple Folders within Multiple Folders
- aws s3 cp - Copy only specific subfolder tree using awscli
- How to sort and copy numbered files into incremented folders
- Moving files from a Zipped folder to respective folders(name of the folders to be derived from file names)
- Correct date/time metadata for files on sharepoint based on file information from Word/Excel
Related Questions in FILE-ORGANIZATION
- PermissionError: [WinError 32] The process cannot access the file because it is being used by another process. This error is shown in shutil.move()
- How to change names of files from one csv column to the next
- Why are files not going to the right folder in my file organizer?
- Is there a way to collapse only files in VS Code’s explorer?
- Is there a way to read information from a spreadsheet and match and add info to music files?
- How does postgres organize files
- How to import multiple csv files at once
- How can I separate many files from one folder into separate folders based on the name of the files?
- organisable file catalog which applies changes to original files in different locations
- Downloading images from URLs in CSV file with Python
- How do I move file types not a specific file in PyCharm?
- Bootstrap, jquery, ERR_FILE_NOT_FOUND
- Python: how to move through folder recursively and shutil.move() files to target folders
- How to split an ansible role's `defaults/main.yml` file into multiple files?
- What is a recommended folder and file structure to use when working with Timber?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
So the answer to this is obviously very subjective. There is no convention for how best to organize your folder, files and project/theme. A great starting point is the Timber Starter theme, which is made by the people who make Timber. You can find that here: https://github.com/timber/starter-theme
I am also going to share with you a project I recently completed with Timber and show you how it is organized. Unfortunately, I cannot share the repo with you as it was for work and the repo is private, however the file and folder structure is all that really matters here.
I started this project, and all Timber projects with the Timber starter theme, so that is my starting point. Inside of the Templates folder, I have the following
CPT = stands for Custom Post Types. Each CPT has its own folder inside of this folder and all of my .twig files for that specific CPT go there. For example: CPT > Staff > image.twig, biography.twig, etc.
components = this file contains things like the header, footer, navigation, mobile navigation, etc. These are all .twig files that are used throughout various pages on my site.
pages = this folder contains folders for each page. I like to break each page specifically into "components" and place each page specific component into its page specific folder.
For example, inside of this pages folder I have a folder called "home-page." This contains all of the components for the home page. So I might have a hero.twig, home-page-slider.twig, mission-statement.twig etc. I break each piece/component of the home page down and create a specific .twig file for each and place them within this folder.
I repeat this process for each and every custom page/template I am making.
That is about it, at least for this project anyways. I hope this gives you a general idea about how best to organize your files. The key, is to do whatever makes sense to you, and if you are working as a team, whatever you and your fellow team members agree upon.
For example you might want to rename what I called my "components" folder to "partials" as you might be more familiar with that terminology. It honestly does not matter what you do as long as it makes sense to you and whomever is going to be in this code base. Remember, what makes sense right now, may not make sense 6 months to a year from now. So think ahead too.
The way I approach all of this is what is the simplest way to convey what each file's role is. I shouldn't have to think or look at a readme. The filenames, folder names and structure should be as self explanatory as possible. I like to remind myself of the KISS principle in these situations... "Keep it simple stupid!"
https://en.wikipedia.org/wiki/KISS_principle
Hope that helps.