Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SEO markups to newsitem html file #1132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ResendeTech
Copy link
Contributor

@ResendeTech ResendeTech commented Oct 18, 2024

User description

Continuation of issue #489


PR Type

enhancement, documentation


Description

  • Added Schema.org JSON-LD markup to the news_item.html template to improve SEO.
  • Implemented NewsArticle type with metadata including headline, publication date, and publisher.
  • Included conditional metadata fields for description, topics, and tags to provide more context to search engines.

Changes walkthrough 📝

Relevant files
Enhancement
news_item.html
Add Schema.org JSON-LD markup for SEO in news item             

news/templates/news/news_item.html

  • Added JSON-LD script block for SEO.
  • Implemented Schema.org NewsArticle markup.
  • Included metadata such as headline, publication date, and publisher.
  • Added conditional fields for description, topics, and tags.
  • +37/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    489 - Fully compliant

    Fully compliant requirements:

    • Add schema.org markup to pages for increased SEO
    • Implement schema.org markup for News: NewsItem
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Potential JSON-LD Error
    The JSON-LD script might have trailing commas which could cause parsing errors. Validate the JSON output, especially for the conditional blocks.

    Missing Author Information
    The schema.org markup for NewsArticle typically includes author information. Consider adding author details if available in the page context.

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Security
    Use Django's built-in JSON escaping mechanism to enhance security and ensure proper JSON formatting

    Consider using Django's json_script template filter to safely render JSON data in
    the script tag. This helps prevent potential XSS vulnerabilities and ensures proper
    JSON escaping.

    news/templates/news/news_item.html [48-80]

     <script type="application/ld+json">
    -{
    -  "@context": "https://schema.org",
    -  "@type": "NewsArticle",
    -  "headline": "{{ page.title }}",
    -  "datePublished": "{{ page.publication_date|date:'Y-m-d' }}",
    -  ...
    -}
    +  {{ json_data|json_script:"newsArticleData" }}
     </script>
    Suggestion importance[1-10]: 9

    Why: This suggestion addresses a potential security vulnerability by using Django's json_script to safely render JSON data, preventing XSS attacks and ensuring proper JSON escaping. It is highly relevant and improves the security of the code.

    9
    Enhancement
    Include author information in the schema to provide more comprehensive structured data

    Add the author property to the NewsArticle schema if available. This can improve the
    completeness of the structured data and potentially enhance SEO.

    news/templates/news/news_item.html [49-57]

     {
       "@context": "https://schema.org",
       "@type": "NewsArticle",
       "headline": "{{ page.title }}",
       "datePublished": "{{ page.publication_date|date:'Y-m-d' }}",
       "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "{{ page.full_url }}"
       },
    +  {% if page.author %}
    +  "author": {
    +    "@type": "Person",
    +    "name": "{{ page.author }}"
    +  },
    +  {% endif %}
       ...
     }
    Suggestion importance[1-10]: 7

    Why: Adding the author property enhances the completeness of the structured data, which can improve SEO. This is a valuable enhancement, though not critical, as it provides additional context for the NewsArticle schema.

    7
    Include image information in the schema to enhance visual representation in search results and social media

    Add the image property to the NewsArticle schema if a featured image is available.
    This can make the article more visually appealing in search results and social media
    shares.

    news/templates/news/news_item.html [49-57]

     {
       "@context": "https://schema.org",
       "@type": "NewsArticle",
       "headline": "{{ page.title }}",
       "datePublished": "{{ page.publication_date|date:'Y-m-d' }}",
       "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "{{ page.full_url }}"
       },
    +  {% if page.featured_image %}
    +  "image": {
    +    "@type": "ImageObject",
    +    "url": "{{ page.featured_image.url }}",
    +    "width": "{{ page.featured_image.width }}",
    +    "height": "{{ page.featured_image.height }}"
    +  },
    +  {% endif %}
       ...
     }
    Suggestion importance[1-10]: 7

    Why: Including the image property can improve the article's visual appeal in search results and social media, enhancing user engagement. This is a beneficial enhancement for SEO and user experience.

    7

    💡 Need additional feedback ? start a PR chat

    @ResendeTech
    Copy link
    Contributor Author

    image

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant