Best practice for extensions' files

+1 for the first variant

Variant 1. :+1:

I used variant 2 before, but switching to variant 1 had the aforementioned benefits of clarity and maintainability.

I’m using variant 1 for years now.

I am always using V1 and i think its clearer.

I’d go with variant 1, too - I used

EXT:myext/Resources/Private/Ext/[nameofextension]/Templates/...

I do prefer variant 1

One would break existing conventions (in my opinion): https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ExtensionArchitecture/FilesAndLocations/Index.html#reserved-folders

Instead it would be:

EXT:site_demo/
    Configuration/
        TypoScript/
            Extensions/
                news/
                    constants.typoscript
                    setup.typoscript

Not a big difference, but that would mean you still have the extension folder and structure at TSconfig, TypoScript, Resources/Public and Resources/Private. There would be no single folder per extension inside a sitepackage.

TypoScript includes would probably look like:

@import 'EXT:site_demo/Configuration/TypoScript/Extensions/*/setup.typoscript'

I’ve no big preference, I guess both have pro and cons. And everyone would still be free to break best practices anyway.

Just wanted to add the hint after reading the response regarding further folders.

[UPDATE] Removed 2nd TypoScript folder as mentioned by Georg, this was an issue.

I don’t want to touch TypoScript in this decision but I find the 2nd TypoScript directory in your example too much and no need for it

Both the “Not to be discussed” section and the “Extensions” part in the path hint that this is part of a much larger configuration setup. @just2b, to what degree would each version be easier in that light?
V2 doesn’t seem to have room for an additional level to separate various types of templates.

From a teaching and personal point of view (I have a couple of classes at a Higher Educational Facility) I also vote for V1.

Regarding the Convention over Configuration approach for inclusion I’d personally rather see a discussion that tackles the complete extension configuration.
CoC (especially when it changes over versions for any reason) can be highly counter-intuitive for beginners, especially when it is mixed with a non-CoC approach.

There those 2 big target groups using TYPO3. On the one hand there are tons of simple sites with 1 page tree and there are others with multi sites and variants which require some having fallbacks and others a completly different setup. I would like to concentrate on the easier setups because it is very hard to support the special projects which require special setups anyway…

I’m for variant 1, too.
Besides, we’re already doing that.

V1, we use it for all projects as it’s much easier to understand IMHO

V2 is clearer for us.

I use V1 since years now and would love to see it as best practice as well.

Can you give some reasons?

Never really thought about it and always used V2. But reading this and thinking about it makes me think V1 way better!

We used V1 before. But for our integrators it was always hard to understand why there are multiple layout, partial and template folders in nested directories.

We then switched to V2 (including the content elements and pages that are not part of this discussion). Since then the folder structure of our provider extension is clearer for us. For this structure we dispense with the fast copying back and forth.

Since I am developing with TYPO3, there was always V1 recommended and used as best practice.
IMO it is consistent through all EXTs in TYPO3-land an shouldn’t stop in an sitepackage-extension or overriding-extension.
I think that makes and will in future make developing an bit faster an more convenient, because one / I know/s where to look for changes.

I’m using V1 and vote for it.