0

페이지와 같이 항목 세부 사항에 대해 다른 OG 태그를 생성하려고합니다. Angular 용 https://github.com/nglibs/meta 모듈을 사용하여 페이지의 메타 태그를 생성합니다. 브라우저에서는 잘 작동하지만 페이스 북의 스크래퍼는 원본 index.html 파일을로드하고 생성 된 태그는 표시되지 않습니다. 내가 조사한 바에 따르면 메타 태그를 생성하는 데 서버 측 로직이 필요하고 메타 태그를 생성하는 데 자바 스크립트를 사용하지 않아야하므로 페이스 북은 올바른 메타를 사용할 수 있습니다. MEAN 스택에이 문제에 대한 해결책이 있습니까? (그렇다면 왜 이런 식으로 쓸모가 없으므로 @gglibs/meta 모듈을 사용하여 메타 태그를 생성 할 필요가 없습니다)MEAN 스택에서 Open Graph 태그를 동적으로 생성합니다. (Angular 2+)

답변

0

ejs 템플릿을 사용하여 색인 파일을 렌더링 할 수 있습니다. 아래처럼. EJS에서 더 연구를 위해이 link

<!doctype html> 
 
<html lang="en" xmlns="http://www.w3.org/1999/html"> 
 
<head> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0" /> 
 

 
    <link href="/css/somecss.css" rel="stylesheet" /> 
 

 
    
 
    <title>Your site</title> 
 
    <meta content="<%- metaTagsDescription %>" name="description" /> 
 
    <meta content="<%- metaTagsRobots %>" name="robots" /> 
 
    <meta content="<%- metaTagsKeyWords %>" name="keywords" /> 
 

 
    <!-- Facebook meta tags--> 
 
    <meta property="og:type" content="<%- metaTagsType %>" /> 
 
    <meta property="og:title" content="<%- metaTagsTitle %>" /> 
 
    <meta property="og:image" content="<%- metaTagsImg %>" /> 
 
    <meta property="og:url" content="<%- metaTagsUrl %>" /> 
 
    <meta property="og:description" content="<%- metaTagsDescription %>" /> 
 

 
    
 
</head> 
 
<body > 
 
    <section id="app"></section> 
 
    <script src="/bundle.js"></script> 
 
</body> 
 
</html>

에 따라