• Hello,

    I am trying to create a block theme but I seem to be running into a few problems:

    • If I add an index.html file to my templates folder -> It shows an empty page but it shows the template Editor in the backend
    • If I remove the index.html file -> the template editor in the backend is gone
    • It shows the template parts in the backend, but I do not seem to be able to create new ones in the backend as I can with the index.html file in the templates folder
      • add_theme_support( ‘block-templates’ );
      • add_theme_support( ‘block-template-parts’ );
    • I created a block with the get_header and get_footer function, but then the favicons don’t seem to work.. It loads the wp_head twice and my favicon load inside of my <div> with class wp-site-blocks..

    So there is always an issue.. I want to create an archive page for my post post type (the default one), but with a custom layout.. I do not think this should be rocket science..

    How do I create the index.html file properly with my get_header & get_footer functions and that it shows the editor in the backend?

    • This topic was modified 1 year, 3 months ago by elkex.
    • This topic was modified 1 year, 3 months ago by elkex.
    • This topic was modified 1 year, 3 months ago by elkex.
Viewing 1 replies (of 1 total)
  • If I add an index.html file to my templates folder -> It shows an empty page but it shows the template Editor in the backend
    If I remove the index.html file -> the template editor in the backend is gone

    So far, so good. This is the expected behavior for block themes.

    So, no “problem” here to solve.

    It shows the template parts in the backend, but I do not seem to be able to create new ones in the backend as I can with the index.html file in the templates folder

    Template Parts can be found under “Patterns”.

    I just created a new theme folder, added a blank style.css file and a blank templates/index.html file and everything worked out of the box: I can create new templates and template parts.

    Also, note that if you’re creating your own HTML template parts, they should be placed in the parts folder. But this is not required to create new template parts from the site editor.

    add_theme_support( ‘block-templates’ );
    add_theme_support( ‘block-template-parts’ );

    As the documentation notes, these are only relevant for non-block-based themes, as block-based themes already support block-based template parts (and templates) as part of the site editor.

    So if you’re developing a new block theme, that’s totally unnecessary.

    I created a block with the get_header and get_footer function, but then the favicons don’t seem to work.. It loads the wp_head twice and my favicon load inside of my <div> with class wp-site-blocks..

    I can’t comment on that, as I don’t know how you created this. But, note that block themes don’t use WordPress’ traditional PHP template tags in their HTML templates/parts.

    How do I create the index.html file properly with my get_header & get_footer functions and that it shows the editor in the backend?

    As noted above, block themes don’t use WordPress’ PHP template tags in their templates/parts. And from this documentation“necessary PHP hooks that you would add to a classic theme, including wp_head(), wp_body_open(), and wp_footer(), are also added automatically. The markup that is inside the template file is printed between the opening and closing body tags.”

    So there is always an issue.. I want to create an archive page for my post post type (the default one), but with a custom layout.. I do not think this should be rocket science..

    Indeed, it’s not rocket science. It’s block theme development.

    And it seems — at least to me — that the real “problem” here is a lack of basic understanding of how block themes work, from a theme developer’s point of view.

    And the “fix” for that is to invest a little time to learn and understand the fundamentals… sort of situational awareness.

    The following resources should help in this regard.

    https://learn.www.ads-software.com/course/a-developers-guide-to-block-themes-part-1/

    https://learn.www.ads-software.com/course/a-developers-guide-to-block-themes-part-2/

    https://developer.www.ads-software.com/block-editor/how-to-guides/themes/block-theme-overview/

Viewing 1 replies (of 1 total)
  • The topic ‘Block theme empty index.html or get_header & get_footer’ is closed to new replies.