以下是一种基本的 Typecho 双栏主题代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset='<?php $this->options->charset(); ?>'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title><?php $this->archiveTitle(' &raquo; ', '', ' - '); ?><?php $this->options->title(); ?></title>
    <link href='<?php $this->options->themeUrl('style.css'); ?>' rel='stylesheet' />
    <?php $this->header(); ?>
</head>
<body>
    <div id='wrapper'>
        <header id='header'>
            <h1><a href='<?php $this->options->siteUrl(); ?>'><?php $this->options->title(); ?></a></h1>
            <p><?php $this->options->description() ?></p>
        </header>
        <div id='main'>
            <div id='content'>
                <?php while($this->next()): ?>
                    <article>
                        <h2><a href='<?php $this->permalink() ?>'><?php $this->title() ?></a></h2>
                        <p class='meta'><?php $this->category(', '); ?> | <?php $this->date('F j, Y'); ?></p>
                        <div class='entry'><?php $this->content('Read more &raquo;'); ?></div>
                    </article>
                <?php endwhile; ?>
                <nav id='page-nav'><?php $this->pageNav(); ?></nav>
            </div>
            <aside id='sidebar'>
                <div class='widget'>
                    <h3>Categories</h3>
                    <ul>
                        <?php $this->widget('Widget_Metas_Category_List')->parse('<li><a href='{permalink}'>'{name}</a> ({count})</li>'); ?>
                    </ul>
                </div>
                <div class='widget'>
                    <h3>Recent Posts</h3>
                    <ul>
                        <?php $this->widget('Widget_Contents_Post_Recent')->parse('<li><a href='{permalink}'>'{title}</a></li>'); ?>
                    </ul>
                </div>
            </aside>
        </div>
        <footer id='footer'>
            <p>&copy; <?php echo date('Y'); ?> <?php $this->options->title() ?>.</p>
        </footer>
    </div>
</body>
</html>

这是一个基本的双栏布局,左侧是文章列表,右侧是侧边栏。可以根据自己的需求进行修改和定制。注意,在 Typecho 中,需要将主题代码放在 theme 目录下,命名为 index.php

Typecho 双栏主题代码示例 - 如何创建简洁布局

原文地址: https://www.cveoy.top/t/topic/lRoP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录