아래코드는 그누보드 게시물 메타 태그 자동 생성해줍니다.
[code]
<?php
// head.php 혹은 head.sub.php의 <head> 부분에 아래 코드를 추가합니다.
// 페이지 종류에 따라 메타 정보 결정
if (defined('G5_IS_VIEW')) {
// 1. 게시글 상세보기 페이지인 경우
// 게시글 제목 (예: $view['wr_subject']는 게시글 제목을 담고 있다고 가정)
$meta_title = isset($view['wr_subject']) ? $view['wr_subject'] : $config['cf_title'];
// 게시글 내용에서 HTML 태그 제거 후 요약 (최대 160자)
if (isset($view['wr_content'])) {
$content = strip_tags($view['wr_content']);
$meta_description = mb_substr($content, 0, 160, 'UTF-8');
} else {
$meta_description = $config['cf_content'];
}
// 게시글에 태그(키워드)가 입력되어 있다면 이를 사용
$meta_keywords = isset($view['wr_tags']) ? $view['wr_tags'] : '';
} else {
// 2. 목록, 메인 페이지 등 기타 페이지인 경우
$meta_title = $config['cf_title']; // 예: 사이트 기본 제목
$meta_description = "기본설명 입력"; // 예: 사이트 기본 설명
$meta_keywords = "키워드입력"; // 예: 사이트 기본 키워드
}
?>
<!-- 메타 태그 출력 -->
<meta name="title" content="<?php echo htmlspecialchars($meta_title); ?>">
<meta name="description" content="<?php echo htmlspecialchars($meta_description); ?>">
<meta name="keywords" content="<?php echo htmlspecialchars($meta_keywords); ?>">
[/code]
댓글 5개
게시글 목록
| 번호 | 제목 |
|---|---|
| 24318 | |
| 24317 | |
| 24315 | |
| 24309 | |
| 24294 | |
| 24293 | |
| 24277 | |
| 24262 | |
| 24260 | |
| 24253 | |
| 24251 | |
| 24236 | |
| 24233 | |
| 24228 | |
| 24226 | |
| 24221 | |
| 24214 | |
| 24203 | |
| 24201 | |
| 24199 | |
| 24196 | |
| 24195 | |
| 24194 | |
| 24192 | |
| 24191 | |
| 24187 | |
| 24185 | |
| 24183 | |
| 24172 | |
| 24168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기