typecho网站 rizhi主题的标题去掉分类名称的写法

typecho程序搭建的网站使用rizhi主题标题有个不好的地方就是会收录分类的名称:如下图:

rizhi主题的标题

这样很不利于seo优化,因为没有必要这样设置,而且如果我之前的页面标题是正常显示的话,使用这个主题会导致标题被简单修改,简单说就是多加了部分无用的标题,显然是多余的。

这样对于SEO优化是很不利的,所以就简单修改一下:找到主题的header文件,然后删除。

<?php if ($this->is('post')) $this->category(',', false);?>

这段代码删掉就可以了,如果不行,可以多试试附近的代码删减,记得备份。

下方就是备份的源代码:

<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="<?php $this->options->charset(); ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title><?php if($this->_currentPage>1) echo '第 '.$this->_currentPage.' 页 - '; ?><?php $this->archiveTitle(array(
            'category'  =>  _t('%s'),
            'tag'       =>  _t('%s'),
            'search'    =>  _t('%s'),
            'date'      =>  _t('%s'),
            'author'    =>  _t('%s')
        ), '', ' - '); ?><?php if ($this->is('post')) $this->category(',', false);?><?php if ($this->is('post')) echo ' - ';?><?php $this->options->title(); ?><?php if ($this->options->titleDescription): ?><?php if ($this->is('index')) echo ' - '; ?><?php if ($this->is('index')) $this->options->titleDescription(); ?><?php endif; ?></title>
        <link rel="dns-prefetch" href="//cdn.staticfile.org" />
        <link rel="dns-prefetch" href="//sdn.geekzu.org" />
    <link rel="stylesheet" href="<?php $this->options->themeUrl('/css/style.min.css'); ?>">
    <?php if ($this->options->userwidth == 'w1200'): ?><link rel="stylesheet" href="<?php $this->options->themeUrl('/css/w1200.css'); ?>"><?php elseif ($this->options->userwidth == 'w1080'): ?><link rel="stylesheet" href="<?php $this->options->themeUrl('/css/w1080.css'); ?>"><?php elseif ($this->options->userwidth == 'w1000'): ?><link rel="stylesheet" href="<?php $this->options->themeUrl('/css/w1000.css'); ?>"><?php else: ; ?><?php endif; ?>
    <?php if ($this->options->dark): ?><link rel="<?php if($_COOKIE['night'] != '1'){echo 'alternate ';} ?>stylesheet" href="<?php $this->options->themeUrl('/css/dark.min.css'); ?>" title="dark"><?php endif; ?>
    <?php if ($this->options->pjax || $this->options->imgbox || $this->options->lazyload): ?><script src="//cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script><?php endif; ?>
    <?php if ($this->options->imgbox): ?><link rel="stylesheet" href="//cdn.staticfile.org/fancybox/3.5.2/jquery.fancybox.min.css"><?php endif; ?>
    <?php if ($this->options->prism): ?><link rel="stylesheet" href="<?php $this->options->themeUrl('/css/prism.min.css'); ?>"><?php endif; ?>
    <?php if ($this->options->emoji): ?><link rel="stylesheet" href="<?php $this->options->themeUrl('/css/OwO.min.css'); ?>"><script src="<?php $this->options->themeUrl('/js/OwO.min.js'); ?>"></script><?php endif; ?>
    <?php if ($this->options->icoUrl): ?><link rel='icon' href='<?php $this->options->icoUrl() ?>' type='image/x-icon' /><?php endif; ?>
    <?php $this->header("commentReply=&antiSpam=&generator=&template=&pingback=&wlw=&xmlrpc=&rss1=&atom=&rss2=/feed"); ?>
    <?php if ($this->options->bodybg): ?>
    <style>body{background-repeat:repeat!important;background-size:auto!important}</style>
    <?php endif; ?>
    <style><?php $this->options->css(); ?></style>
</head>
<body>
<div class="container">
    <header id="header" class="<?php if ($this->options->bgimg){echo 'header';} ?>">
        <h1 class="site-title">
            <?php if ($this->options->logoUrl): ?>
                <a href="<?php $this->options->siteUrl(); ?>">
                    <img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" />
                </a>
            <?php else: ?>
                <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a>
            <?php endif; ?>
        </h1>
    <?php if ($this->options->sitede): ?><p class="site-description"><?php $this->options->description() ?></p><?php endif; ?>
    </header>
    <div id="mainbody">
    <div class="menubar">
    <div class="mhome"><a <?php if($this->is('index')): ?> class="current"<?php endif; ?> href="<?php $this->options->siteUrl(); ?>"><?php _e('首页'); ?></a></div>
    <button id="menubutton" disable="enable" onclick="var qr = document.getElementById('menu'); if (qr.style.display === 'block') {qr.style.display='none';} else {qr.style.display='block'}">
                <span><i></i><i></i><i></i></span></button>
    <div id="menu">
                <nav id="nav-menu" role="navigation">
                <li class="whome"><a <?php if($this->is('index')): ?> class="current"<?php endif; ?> href="<?php $this->options->siteUrl(); ?>"><?php _e('首页'); ?></a></li>


        <?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php if ($category->have()): ?>
<?php while ($category->next()): ?>
    <?php if ($category->levels == 0): ?>
        <?php $children = $category->getAllChildren($category->mid); ?>
        <?php if (empty($children)) :?>
            <li <?php if ($this->is('post')): ?><?php if ($this->category == $category->slug): ?> class="current"<?php endif; ?><?php else: ?><?php if ($this->is('category', $category->slug)): ?> class="current"<?php endif; ?><?php endif; ?>><a href="<?php $category->permalink() ?>"> <?php $category->name() ?></a></li>
        <?php else : ?>
            <li id="has-sub" <?php if ($this->is('post')): ?><?php if ($this->category == $category->slug): ?> class="current"<?php endif; ?><?php else: ?><?php if ($this->is('category', $category->slug)): ?> class="current"<?php endif; ?><?php endif; ?>>
                <a href="<?php $category->permalink() ?>"><?php $category->name() ?></a>
                <ul>
                    <?php foreach ($children as $child ): ?>
                        <?php $child = $category->getCategory($child) ?>
                        <li <?php if ($this->is('category', $child["slug"])): ?> class="current"<?php endif; ?>><a href="<?php echo $child['permalink']; ?>"> <?php echo $child['name']; ?></a></li>
                    <?php endforeach ?>
                </ul>
            </li>
        <?php endif ?>
    <?php endif ?>
<?php endwhile; ?>
<?php endif ?>

                    <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
                    <?php while($pages->next()): ?>
                    <?php if ($pages->slug != 'goto'): ?>
                    
                    <?php endif ?>
                    <?php endwhile; ?>
                    
                    <?php $this->options->menunav() ?>

                    <li class="menu-search"><form id="search" method="post" action="./" role="search">
                    <input type="text" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>" required/>
                    <button type="submit" class="submit"><?php _e('搜索'); ?></button>
                    </form></li>
                    <div class="clearfix"></div>
                </nav>
    </div>
    <div class="clearfix"></div>
    </div>

👋 感谢您的观看!

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享