Creating a complete default Blogger template from scratch using XML involves defining various sections such as the header, footer, main content area, sidebar, and widgets. Below is a simplified example of a Blogger template that you can use as a starting point.
Please note: This is a basic template to help you understand the structure. You may need to modify and enhance it according to your specific needs and design preferences.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
-->
<b:template xmlns="http://www.w3.org/1999/xhtml"
xmlns:b="http://www.google.com/2005/gml/b"
xmlns:data="http://www.google.com/2005/gml/data"
xmlns:expr="http://www.google.com/2005/gml/expr">
<b:skin><![CDATA[
/* CSS Styles */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
#header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
#main {
display: flex;
margin: 20px;
}
#content {
flex: 3;
margin-right: 20px;
}
#sidebar {
flex: 1;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
#footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 10px;
position: fixed;
width: 100%;
bottom: 0;
}
.post-title {
font-size: 24px;
margin-bottom: 10px;
}
.post-content {
font-size: 16px;
}
/* Additional styles as needed */
]]></b:skin>
<b:includable id='main'>
<b:section id='header' class='header' maxwidgets='1' showaddelement='no'>
<b:widget id='Header1' type='Header' visible='true'>
<b:widget-settings>
<b:widget-setting name='title'>My Blog Title</b:widget-setting>
<b:widget-setting name='description'>A description of my blog.</b:widget-setting>
</b:widget-settings>
<b:includable id='widget'>
<div id='header'>
<h1><data:widget.title/></h1>
<p><data:widget.description/></p>
</div>
</b:includable>
</b:widget>
</b:section>
<b:section id='main' class='main' maxwidgets='1' showaddelement='no'>
<div id='main'>
<div id='content'>
<b:include name='blog'/>
</div>
<div id='sidebar'>
<b:section id='sidebar1' class='sidebar' maxwidgets='5' showaddelement='yes'>
<b:widget id='Text1' type='Text' visible='true'>
<b:widget-settings>
<b:widget-setting name='content'>
<![CDATA[
<h2>About Me</h2>
<p>This is a sidebar widget. You can add more widgets here.</p>
]]>
</b:widget-setting>
</b:widget-settings>
<b:includable id='widget'>
<div class='widget'>
<data:widget.render/>
</div>
</b:includable>
</b:widget>
<!-- Add more widgets here -->
</b:section>
</div>
</div>
</b:section>
<b:section id='footer' class='footer' maxwidgets='1' showaddelement='no'>
<b:widget id='Footer1' type='HTML' visible='true'>
<b:widget-settings>
<b:widget-setting name='content'>
<![CDATA[
<p>© <data:year/> My Blog. All rights reserved.</p>
]]>
</b:widget-setting>
</b:widget-settings>
<b:includable id='widget'>
<div id='footer'>
<data:widget.content/>
</div>
</b:includable>
</b:widget>
</b:section>
</b:includable>
<b:includable id='blog'>
<b:loop values='data:posts' var='post'>
<article class='post'>
<h2 class='post-title'><data:post.title/></h2>
<div class='post-content'>
<data:post.body/>
</div>
<div class='post-meta'>
<span>Posted on <data:post.date/></span>
<span> by <data:post.author/></span>
</div>
</article>
</b:loop>
<b:if cond='data:blog.pageType == "index"'>
<div class='pagination'>
<b:include name='blog-pager'/>
</div>
</b:if>
</b:includable>
<b:includable id='blog-pager'>
<data:blog.pager/>
</b:includable>
</b:template>
Explanation of the Template Structure:
-
Header Section (#header):
- Contains the blog title and description.
- Uses a
Header widget to allow easy customization within the Blogger interface.
-
Main Content Area (#main):
- Divided into two parts:
- Content (
#content): Displays blog posts using a loop to iterate through each post.
- Sidebar (
#sidebar): Contains widgets like "About Me". You can add more widgets by duplicating the Text widget or adding different widget types.
-
Footer Section (#footer):
- Displays footer information, such as copyright.
-
Styles (<b:skin>):
- Basic CSS styling for layout and appearance.
- You can expand these styles or link to external stylesheets as needed.
-
Widgets and Sections:
- Uses Blogger's
b:section and b:widget tags to define areas where blog owners can add, remove, or rearrange widgets via the Blogger dashboard.
-
Loop for Posts:
- Iterates through each blog post and displays the title, content, and metadata like date and author.
-
Pagination:
- Includes pagination controls to navigate between different pages of posts.
How to Use This Template:
-
Backup Your Current Template:
- Before making any changes, always back up your existing template. You can do this in the Blogger dashboard under Theme > Backup/Restore.
-
Create a New Template:
- Go to Theme > Edit HTML in your Blogger dashboard.
- Replace the existing code with the provided XML code.
-
Customize:
- Modify the CSS in the
<b:skin> section to match your desired design.
- Update the blog title and description in the
Header widget settings.
- Add or remove widgets in the sidebar by editing the
<b:section id='sidebar1'>.
-
Add Additional Features:
- Enhance the template by adding more widgets, custom JavaScript, SEO tags, and responsive design elements as needed.
Additional Resources:
Important Considerations:
- Validation: Ensure your XML is well-formed to prevent template errors. You can use online XML validators to check your code.
- Responsive Design: Consider making your template responsive to provide a good user experience on all devices. This involves using media queries and flexible layouts in your CSS.
- Performance: Optimize your CSS and scripts to ensure fast loading times.
By starting with this basic template, you can expand and customize it to create a unique and fully functional Blogger theme that suits your needs.