반응형

프로그래머가 분석한 티스토리 블로그 해시태그 작성 요령

결론부터 말합니다.

 

1. 반복단어 금지

2. 통계를 보고 해시태그 수정 (자동완성, 연관 검색어)


1. 반복 단어 사용하지 마세요!

 

구글이나 네이버 검색시, 검색시간이 0.1초도 걸리지 않습니다.

이 짧은 시간에 기계가 수십만개 사이트의 내용 전부 처음부터 끝까지 검색할 수 있을까요?

 

검색 시간을 줄이기 위해 같은 단어를 압축 등 여러가지 전략으로 검색합니다.

 

예를 들면) 단어 -> 글자 단순화 합니다.

해시태그라는 단어를 h라는 1글자로 전부 바꿉니다.

4글자인 1단어가 1글자로 변하죠? 모든 '해시태그'라는 단어를 전부 'h'라는 한 글자로 바꾸고

이 단어의 갯수도 헤아립니다.

이런한 일련의 과정을 통해 핵심 단어를 선별하여 검색 시간을 줄입니다.

 

그러므로 검색엔진은 동일한 단어는 1개로 묶어 취급합니다.

기계가 검색하기 때문에 같은 단어를 3번 검색하나 100번 검색하나 동일한 결과가 나오게 됩니다.

 

그 외에도 해시태크의 본래 목적은 전체 내용을 유추하는 것입니다.

제목과 비슷한지만, 단어를 나열하여 전체적인 내용을 나열한 것입니다.

 

제목은 사람들의 관심을 사야하기 때문에 자극적인 단어를 쓰지만, 해시태그는 성질이 다르죠!

 

내용을 유추해야 하는데 같은 단어가 있다면 아무런 도움이 되지 않기 때문입니다.

 

그러면 해시태그 작성을 어떻게 해야할까요?

 

키워드 분류입니다.

 

현대, 기아, BMW, 벤츠 이런것을 '자동차', '메이커'처럼 분류 할 수 있습니다.

 

같은 단어를 사용하고 싶다면 자동차, 메이커 처럼 연관 단어를 사용하세요.


2. 해시태그는 무조건 수정하세요!

 

처음 글을 배포하고, 유입 검색어를 이용하여 수정해야 합니다.

 

  • 사람들의 직접 유입한 검색 키워드를 이용하세요.

 

유입 키워드 통계 예시

여기에서 중복되는 단어의 순위대로 해시태그에 추가하세요!

 

  • 검색엔진을 이용하세요.

포스트의 핵심내용을 검색해보세요. 연관 검색어 또는 자동완성을 참고하세요.

 

구글 자동완성 예시

수 많은 사람들이 검색한 이력을 바탕으로 만들어 지는 자동완성 기능입니다.

 

여기에 있는 단어들을 사용하면 유리합니다.

검색엔진은 저런 단어를 위주로 먼저 검색할 확률이 높기 때문이죠.

 

기계인 검색 엔진은 자동완성이나 연관 검색어의 순위를 어떻게 정할까요?

 

'검색 수'를 떠올리 셨을 거에요! 네이버의 경우 순간 검색순위 라는 서비스를 제공하죠!

하지만 검색엔진은 순간이 아닌, 누적으로 처리를 합니다. 그러기 위해선 단순히 숫자로만 할 수 없습니다.

 

정확성을 높이고 사용자의 편의성을 위해 고도의 전략을 이용하죠.

 

그중 하나가 페이지에 머무르는 시간, 클릭 빈도와 같은 정보를 이용하는 것입니다.

 

 

 

유익한 정보로 도움이 되셨길 바랍니다:)

반응형
반응형

html 세팅

<!-- child component HTML -->
<ion-searchbar autocomplete="on" [(ngModel)]="searchbarInput" (ionInput)="filterItems($event)"
  debounce="500">
</ion-searchbar>

<ion-list *ngIf="listActive">
  <ion-item *ngFor="let item of items" (click)="fillSearchbarText(item.title)" style="cursor: pointer;">
    <ion-label>
      <strong>{{item.title}}</strong>
    </ion-label>
  </ion-item>
</ion-list>

<ion-searchbar

autocomplete="on" : 자동완성 기능을 사용합니다.

[(ngModel)]="searchbarInput" : searchbarInput과 ion-searchbar의 input을 2-way바인딩 합니다.

(ionInput)="filterItems($event)" : Input에 입력될 때 마다 filterItems() 메쏘드를 실행합니다.

debounce="500" : (ionInput)의 작동 시간에 반응 시간을 설정합니다. (기본은 250)

 

<ion-list *ngIf="listActive" : ion-list를 표시할 때 쓰는 flag입니다.

<ion-item *ngFor="let item of items" : filterItems로 필터링 된 값을 뿌립니다.

<ion-item (click)="fillSearchbarText(item.title)" : 해당 아이템의 값을 바인딩된 searchbarInput에 넣습니다.

 

// child component ts file
import { Component, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { DeviceCommon, ItemView } from '../device-common';

class ItemView {
  title: string
}

@Component({
  selector: 'app-autocomplete-searchbar',
  templateUrl: './autocomplete-searchbar.component.html',
  styleUrls: ['./autocomplete-searchbar.component.scss'],
})
export class AutocompleteSearchbarComponent {

  @Input() itemViewArr: ItemView[];
  @Output() itemSelected = new EventEmitter<string>();
  @ViewChild('', { static: true }) searchbarInput: string;

  private listActive = false;
  private items: ItemView[] = [];

  constructor(private common: DeviceCommon) { }

  initializeItems() {
    this.items = [...this.itemViewArr];
  }

  includeAnySpell = (result: ItemView[], item: ItemView, term: string) => {
    const include = (str: string) => str.toLowerCase().indexOf(term.toLowerCase()) > -1;
    if (include(item.title)) {
      result.push(item.title)
    }
    return result;
  }

  filterItems(ev: any) {
    this.initializeItems();
    const term: string = ev.target.value;
    if (term && term.trim() != '') {
      this.listActive = true;
      this.items = this.items.reduce((result: ItemView[], item: ItemView) => this.includeAnySpell(result, item, term), []);
    } else {
      this.listActive = false;
    }
  }

  fillSearchbarText(title: string) {
    this.searchbarInput = title;
    this.listActive = false;
    this.itemSelected.emit(title);
  }

}

@Input() itemViewArr: ItemView[]; : 부모 컴포넌트에서 받은 property값입니다.

@Output() itemSelected = new EventEmitter<string>(); : 부모 컴포넌트에 보낼 이벤트입니다.

@ViewChild('', { static: true }) searchbarInput: string; : [(ngModel)]="searchbarInput" 바인딩을 선언합니다.

 

  initializeItems() {
    this.items = [...this.itemViewArr];
  }

 

 

외부에서 받은 itemViewArr값을 this.items에 복사하여 넣습니다.

 

  includeAnySpell = (result: ItemView[], item: ItemView, term: string) => {
    const include = (str: string) => str.toLowerCase().indexOf(term.toLowerCase()) > -1;
    if (include(item.title)) {
      result.push(item.title)
    }
    return result;
  }

  filterItems(ev: any) {
    this.initializeItems();
    const term: string = ev.target.value;
    if (term && term.trim() != '') {
      this.listActive = true;
      this.items = this.items.reduce((result: ItemView[], item: ItemView) => this.includeAnySpell(result, item, term), []);
    } else {
      this.listActive = false;
    }
  }

includeAnySpell = (result: ItemView[], item: ItemView, term: string) => {...} : Array.reduce에 사용할 함수 선언합니다.

const include = (str: string) => str.toLowerCase().indexOf(term.toLowerCase()) > -1; : input에서 입력된 값중에 한글자라도 포함되면 true 를 반환하는 함수입니다.

 

filterItems(ev: any) : <ion-searchbar (ionInput)="filterItems($event)" 로써 입력될 때 마다 작동합니다.

this.initializeItems(); : 아이템을 초기화합니다.

const term: string = ev.target.value; : input에 입력된 값을 가져옵니다.

 

fillSearchbarText(title: string) {
    this.searchbarInput = title;
    this.listActive = false;
    this.itemSelected.emit(title);
  }

<ion-item 을 클릭했을 때 작동하는 메쏘드 입니다.

this.searchbarInput=title; : 해당 item의 값을 input에 입력합니다.

this.itemSelected.emit(title); : 선택된 값을 부모 컴포넌트에 전달합니다.

 

<!-- parent component HTML -->

<app-autocomplete-searchbar [itemViewArr]="itemViewArr" (itemSelected)="autocompletedValue($event)"
</app-autocomplete-searchbar>

<app-autocomplete-searchbar  : 위의 child component 입니다.

[itemViewArr]="itemViewArr" : child component에서 @Input으로 받을 값 입니다.

[itemViewArr] : child component에서 사용할 property값 입니다.

"itemViewArr" : parent component에서 보내는 ts 값입니다.

 

(itemSelected)="autocompletedValue($event)" :

(itemSelected) : child component의 itemSelected(EventEmitter).emit()이 실행될 때 

"autocompletedValue($event)" : parent component에서 실행 될 메쏘드로 child component에서 값을 받습니다.

 

// parent component ts
itemViewArr: ItemView[] = [];

setItemView() {
this.itemViewArr = [];
  this.msgHouse.msgHouse.forEach(msgRoom => {
    this.itemViewArr.push(new ItemView(msgRoom.title));
  })
}

autocompletedValue(title: string) {
    if (title && title.length) {
	  console.log(title);
    }
  }

 

setItemView() {...} : child component로 들어갈 this.itemViewArr을 채웁니다.

 

autocompletedValue(title: string) : child component에서 보낸 값을 받는 메쏘드 입니다.

 

응용을 하면 아래와 같은 화면도 가능합니다.

f를 입력했을 경우, f가 포함된 모든 단어들이 다 나오도록 할 수 있습니다.

 

반응형

'프로그래밍 > Ionic' 카테고리의 다른 글

아이오닉 form handling  (0) 2020.02.14
Ionic 4 배포하기  (0) 2019.11.08
DataHandling  (0) 2019.10.18
State 관리  (0) 2019.10.12
Styling & Theming  (0) 2019.10.12

+ Recent posts