惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
C
Check Point Blog
雷峰网
雷峰网
小众软件
小众软件
GbyAI
GbyAI
美团技术团队
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
Jina AI
Jina AI
爱范儿
爱范儿
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美

膨胀自留地

使用CloudFlare标记管理功能优雅的使用谷歌分析 四天轻松版北京旅游攻略 Adsense税务居住地证明申请教程:如何申请中国税收居民身份证明以及Google Adsense更新新加坡税务信息教程 常见的 VPS 优化措施 HTML实现table表格移动端自动转为卡片样式 个人网站接入 Google 登录 如何从 GitHub 永久删除泄露的 .env 文件 Cloudflare设置www的域名跳转到不带www的域名 顶级iOS神器!全面解开App Store限制,AssPP Pro保姆级教程 BroadcastChannel将你的 Telegram Channel 转为微博客 Medama开源轻量级网站统计(分析)系统 白嫖一个网站监控面板:uptime-kuma 部署TraffMonetizer利用闲置VPS挂机赚钱 Counterscale-使用CloudflareWorkers部署的免费网站数据统计工具,界面类似umami 封装一个最简单的Axios,避免过度封装! 如何使用Cloudflare Email Routing创建域名邮箱免费发送邮件 使用Cron定时更新Hosts解决Gihub无法访问问题 容器化MariaDB/Mysql实现定时备份 JetBrains全家桶许可证服务器怎么找,JetBrains激活教程 图片加速接口:缓存图片,加速访问,解决防盗链 MySQL模糊查询再也不用like+%了,全文索引介绍及使用简介 为什么这么多人推荐你办理流量卡?流量卡怎么赚钱?怎么避坑? 借助Cloudflare Worker实现Google Analytics反代加速,规避广告屏蔽插件的拦截 etcd入门之在Centos上安装部署 Grafana在linux下安装和基本使用入门 Prometheus介绍、安装和基本功能快速入门 无需加速器,油猴插件解锁xbox云游戏 阿里云盘自动每日签到,无需部署,无需服务器 自定义VSCode终端主题样式 一行 CSS 代码实现响应式布局 – 使用 Grid 实现的响应式布局
Typecho纯代码生成sitemap站点地图
2022-12-31 · via 膨胀自留地

#编程技术 2022-12-31 13:52:27 | 全文 593 字,阅读约需 2 分钟 | 加载中... 次浏览

👋 相关阅读


想要实现 Typecho 纯代码生成 sitemap 站点地图只需要 2 步就够了。

1、在博客主题目录新建 sitemap.php 页面,放入以下代码:

<?php
/**
*HTML版网站地图Sitemap
*
* @package custom
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
  <meta http-equiv="Content-Type" content="text/html; charset=<?php $this->options->charset(); ?>" />
  <title>站点地图 - <?php $this->options->title() ?></title>
  <meta name="keywords" content="站点地图,<?php $this->options->title() ?>" />
  <meta name="copyright" content="<?php $this->options->title() ?>" />
  <link rel="canonical" href="<?php $this->permalink() ?>" />
  <style type="text/css">
    body {font-family: Microsoft Yahei,Verdana;font-size:13px;margin:0 auto;color: #000000;background: #ffffff;width: 990px;margin: 0 auto}
    a:link,a:visited {color:#000;text-decoration:none;}
    a:hover {color:#08d;text-decoration:none;}
    h1,h2,h3,h4,h5,h6 {font-weight:normal;}
    img {border:0;}
    li {margin-top: 8px;}
    .page {padding: 4px; border-top: 1px #EEEEEE solid}
    .author {background-color:#EEEEFF; padding: 6px; border-top: 1px #ddddee solid}
    #nav, #content, #footer {padding: 8px; border: 1px solid #EEEEEE; clear: both; width: 95%; margin: auto; margin-top: 10px;}
  </style>
</head>
<body vlink="#333333" link="#333333">
  <h2 style="text-align: center; margin-top: 20px"><?php $this->options->title() ?>'s SiteMap </h2>
  <center></center>
  <div id="nav"><a href="<?php $this->options ->siteUrl(); ?>"><strong><?php $this->options->title() ?></strong></a> » <a href="<?php $this->permalink() ?>">站点地图</a></div>
  <div id="content">
    <h3>最新文章</h3>
    <ul>
      <?php
      $stat = Typecho_Widget::widget('Widget_Stat');
      $this->widget('Widget_Contents_Post_Recent', 'pageSize='.$stat->publishedPostsNum)->to($archives);
      $year=0; $mon=0; $i=0; $j=0;
      while($archives->next()){
          $year_tmp = date('Y',$archives->created);
          $mon_tmp = date('m',$archives->created);
          $y=$year; $m=$mon;
          if ($year > $year_tmp || $mon > $mon_tmp) {
              $output .= '</ul>';
          }
          $output .= '<li><a href="'.$archives->permalink .'">'. $archives->title .'</a></li>';
      }
      $output .= '</ul>';
      echo $output;
      ?>
    </ul>
  </div>
  <div id="content">
    <li class="categories">分类目录
      <ul><?php $this->widget('Widget_Metas_Category_List')
               ->parse('<li><a href="{permalink}">{name}</a> ({count})</li>'); ?>
      </ul>
    </li>
  </div>
  <div id="content">
    <li class="categories">独立页面</li>
    <ul class="clearfix" id="nav_menu">
      <li><a href="<?php $this->options->siteUrl(); ?>">首页</a></li>
      <?php $this->widget('Widget_Contents_Page_List')
                 ->parse('<li><a href="{permalink}">{title}</a></li>'); ?>
    </ul>
  </div>
  <div id="footer">查看博客首页: <strong><a href="<?php $this->options ->siteUrl(); ?>"><?php $this->options->title() ?></a></strong></div><br />
  <center>
    <div style="text-algin: center; font-size: 11px"><br /> © <?php echo date('Y'); ?> <strong><a href="<?php $this->options ->siteUrl(); ?>" target="_blank"><?php $this->options->title() ?></a></strong> 版权所有<br /><br /><br />
    </div>
  </center>
</body>
</html>

2、Typecho 后台新建 sitemap 页面选择 sitemap.php 模板

图片alt


×