Connect with us

SEO

Three organic search opportunities for your local business

Published

on

Three organic search opportunities for your local business


30-second summary:

  • Following pandemic-driven shopping trends, lots of local businesses had to explore online marketing opportunities
  • Google offers a few great ways for a local business to get found through organic search
  • Local 3 Pack is Google’s search element containing top three local businesses based on your search query
  • To rank in the Local 3 Pack you need to ensure your Google My Business listing is complete and active
  • Third-party local business listings (like Yelp and Tripadvisor) may also drive some organic search visibility so it is a good idea to claim your business there

Local marketing has become even a more trending topic, following the pandemic. Lots of local businesses that used to rely on local footfall were forced to turn to the internet in order to get found by customers. This need for digital transformation brought a huge challenge to just about any local business – how to get found online? 

Step 1: Claim your business profile on Google My Business

Google offers huge organic search visibility to local businesses through the Local 3 Pack that shows up on top of organic results when search intent reflects buying (or doing) something locally.

Local 3 pack is Google’s search element that includes three relevant businesses from Google Maps results:

Source: Screenshot by the author

Ranking your business in the Local 3 Pack is no easy task. It heavily relies on the proximity of those businesses to the customer’s current location.

However, there are a few things you can do to improve your local rankings:

  • Make sure you have a detailed (and original) description of your business and what it is you do
  • Add your website (oftentimes Google would grab text from the associated website and rank a business based on that content). There are also a few great plugins allowing you to embed your local listing onto your website for better visibility.
  • Upload pictures and videos of your office, team, and work environment to give customers/searchers a better view of your business
  • Add your products and services (Note: Services are not believed to have a huge (or any) impact on your local rankings but why not add those anyway)
  • Keep your business categories as relevant as you can as they can harm your local rankings

 

Most importantly, keep an eye on your Google reviews

Business reviews are known to be crucial for your local (and hence Local 3 Pack) rankings, so make sure to keep an eye on your reviews and reply to all of them.

Note that Google may remove your review if they find you have been using manipulative or misleading tactics when getting those reviews, for example:

  • If that review is repeated across other business profiles on other sites (which, by the way, can be quite natural… I’ll be the one to admit that I may leave my favorite business the same review on a few platforms I am registered at. But again, I think we are talking about suspicious patterns here rather than one-on-one cases)
  • If you had a massive influx of reviews overnight
  • If Google suspects that you and your team are reviewing your business pretending to be clients.

While you may notice your competitors implement these manipulative tactics without no obvious negative impact on their rankings, I’d still suggest avoiding these at all costs. 

You can invite your customers to review your business on Google through a short URL that’s specific to your local business and even note that on your business card – you could use QR codes to facilitate this. But you are not allowed to request positive (five-star) reviews or segment your customer base to only invite happy customers to review you.

If you have a budget, investing in ads on Google maps is also a great idea. This could bring in more customers and reviews.

Step 2: Claim your business profile everywhere else

While claiming your business is generally a good idea to get better control over your branded content, it also gives you additional organic exposure because those listings may rank in organic search results and bring additional exposure.

Hence, your next step is identifying important local directories (like Trip Advisor and Yelp)and claiming your business everywhere.

Here’s a huge list of those you can consider.

Source: Brightlocal

Just about any local business out there will need to ensure a strong Yelp presence, for example, so that one will always be on top of your list. Yelp marketing is tricky but if you start getting reviews there, there’s a way to display those reviews on your site to boost your conversions.

When putting your business on maps

  • Make sure your business name and address is consistent across all channels, including the phone number format
  • Complete all available fields and use all available characters! More content generally means higher rankings for your listings!
  • Monitor your listings for reviews, add updates, ensure your business info is up-to-date

Step 3: Develop a hyperlocal content strategy

Similar to how foot traffic works for a local business (passers-by may check a store out of curiosity), a well-planned content marketing strategy can drive customers who never intended to buy anything or didn’t know they needed you.

  • Describe (location-driven) problems your business solves. For instance, a Seattle hairdresser publishes an article on haircuts that work well in the windy or rainy climate.
  • Address some problems that are common in your area. These work best when they are timed to a particular seasonal trend. For instance, a bakery in Albany publishes a checklist of foods to store at home to prepare for a snowstorm.

Here are a few ideas for hyperlocal content:

  • Ideas for local vacations and where your business can be of help
  • Local events and how your brand participates
  • Partnerships like local charities

Take note of local People Also Ask results because those are great sources of hyperlocal content.

Using the PAA feature to boost local SEO visibility

Source: Screenshot by the author

Generally, answering local questions is a great idea.

Let’s take a look at this search query: “how far is Central Park from Times Square” 

People searching for this may not necessarily be looking to buy anything but there are still some opportunities here as your content may give them ideas on where to dine or stay.

Local search resultsSource: Screenshot by the author

The beauty of hyperlocal content marketing is that your clients don’t have to be in the area to find your content: They may be planning a trip to your area and discover your business prior to going. This is something local maps placement won’t be able to help with.

Using semantic search is another good way to come up with hyperlocal content ideas because it will help you identify location-based keywords that are able to generate organic traffic. Here’s how semantic search works:

Source: Screenshot by the author

Conclusion

Organic search provides quite a few opportunities for local businesses to generate traffic and get found by customers. Keep an eye on your local listings and keep creating hyperlocal content to generate relevant traffic for your local business. Good luck!

Ann Smarty is the Founder of Viral Content Bee, Brand and Community manager at Internet Marketing Ninjas. She can be found on Twitter @seosmarty.

Subscribe to the Search Engine Watch newsletter for insights on SEO, the search landscape, search marketing, digital marketing, leadership, podcasts, and more.

Join the conversation with us on LinkedIn and Twitter.





Source link

Continue Reading
Comments

SEO

A Complete Google Search Console Guide For SEO Pros

Published

on

A Complete Google Search Console Guide For SEO Pros


Google search console provides data necessary to monitor website performance in search and improve search rankings, information that is exclusively available through Search Console.

This makes it indispensable for online business and publishers that are keen to maximize success.

Taking control of your search presence is easier to do when using the free tools and reports.

What Is Google Search Console?

Google Search Console is a free web service hosted by Google that provides a way for publishers and search marketing professionals to monitor their overall site health and performance relative to Google search.

It offers an overview of metrics related to search performance and user experience to help publishers improve their sites and generate more traffic.

Search Console also provides a way for Google to communicate when it discovers security issues (like hacking vulnerabilities) and if the search quality team has imposed a manual action penalty.

Important features:

  • Monitor indexing and crawling.
  • Identify and fix errors.
  • Overview of search performance.
  • Request indexing of updated pages.
  • Review internal and external links.

It’s not necessary to use Search Console to rank better nor is it a ranking factor.

However, the usefulness of the Search Console makes it indispensable for helping improve search performance and bringing more traffic to a website.

How To Get Started

The first step to using Search Console is to verify site ownership.

Google provides several different ways to accomplish site verification, depending on if you’re verifying a website, a domain, a Google site, or a Blogger-hosted site.

Domains registered with Google domains are automatically verified by adding them to Search Console.

The majority of users will verify their sites using one of four methods:

  1. HTML file upload.
  2. Meta tag
  3. Google Analytics tracking code.
  4. Google Tag Manager.

Some site hosting platforms limit what can be uploaded and require a specific way to verify site owners.

But, that’s becoming less of an issue as many hosted site services have an easy-to-follow verification process, which will be covered below.

How To Verify Site Ownership

There are two standard ways to verify site ownership with a regular website, like a standard WordPress site.

  1. HTML file upload.
  2. Meta tag.

When verifying a site using either of these two methods, you’ll be choosing the URL-prefix properties process.

Let’s stop here and acknowledge that the phrase “URL-prefix properties” means absolutely nothing to anyone but the Googler who came up with that phrase.

Don’t let that make you feel like you’re about to enter a labyrinth blindfolded. Verifying a site with Google is easy.

HTML File Upload Method

Step 1: Go to the Search Console and open the Property Selector dropdown that’s visible in the top left-hand corner on any Search Console page.

Screenshot by author, May 2022

Step 2: In the pop-up labeled Select Property Type, enter the URL of the site then click the Continue button.

Step 2Screenshot by author, May 2022

Step 3: Select the HTML file upload method and download the HTML file.

Step 4: Upload the HTML file to the root of your website.

Root means https://example.com/. So, if the downloaded file is called verification.html, then the uploaded file should be located at https://example.com/verification.html.

Step 5: Finish the verification process by clicking Verify back in the Search Console.

Verification of a standard website with its own domain in website platforms like Wix and Weebly is similar to the above steps, except that you’ll be adding a meta description tag to your Wix site.

Duda has a simple approach that uses a Search Console App that easily verifies the site and gets its users started.

Troubleshooting With GSC

Ranking in search results depends on Google’s ability to crawl and index webpages.

The Search Console URL Inspection Tool warns of any issues with crawling and indexing before it becomes a major problem and pages start dropping from the search results.

URL Inspection Tool

The URL inspection tool shows whether a URL is indexed and is eligible to be shown in a search result.

For each submitted URL a user can:

  • Request indexing for a recently updated webpage.
  • View how Google discovered the webpage (sitemaps and referring internal pages).
  • View the last crawl date for a URL.
  • Check if Google is using a declared canonical URL or is using another one.
  • Check mobile usability status.
  • Check enhancements like breadcrumbs.

Coverage

The coverage section shows Discovery (how Google discovered the URL), Crawl (shows whether Google successfully crawled the URL and if not, provides a reason why), and Enhancements (provides the status of structured data).

The coverage section can be reached from the left-hand menu:

CoverageScreenshot by author, May 2022

Coverage Error Reports

While these reports are labeled as errors, it doesn’t necessarily mean that something is wrong. Sometimes it just means that indexing can be improved.

For example, in the following screenshot, Google is showing a 403 Forbidden server response to nearly 6,000 URLs.

The 403 error response means that the server is telling Googlebot that it is forbidden from crawling these URLs.

Coverage report showing 403 server error responsesScreenshot by author, May 2022

The above errors are happening because Googlebot is blocked from crawling the member pages of a web forum.

Every member of the forum has a member page that has a list of their latest posts and other statistics.

The report provides a list of URLs that are generating the error.

Clicking on one of the listed URLs reveals a menu on the right that provides the option to inspect the affected URL.

There’s also a contextual menu to the right of the URL itself in the form of a magnifying glass icon that also provides the option to Inspect URL.

Inspect URLScreenshot by author, May 2022

Clicking on the Inspect URL reveals how the page was discovered.

It also shows the following data points:

  • Last crawl.
  • Crawled as.
  • Crawl allowed?
  • Page fetch (if failed, provides the server error code).
  • Indexing allowed?

There is also information about the canonical used by Google:

  • User-declared canonical.
  • Google-selected canonical.

For the forum website in the above example, the important diagnostic information is located in the Discovery section.

This section tells us which pages are the ones that are showing links to member profiles to Googlebot.

With this information, the publisher can now code a PHP statement that will make the links to the member pages disappear when a search engine bot comes crawling.

Another way to fix the problem is to write a new entry to the robots.txt to stop Google from attempting to crawl these pages.

By making this 403 error go away, we free up crawling resources for Googlebot to index the rest of the website.

Google Search Console’s coverage report makes it possible to diagnose Googlebot crawling issues and fix them.

Fixing 404 Errors

The coverage report can also alert a publisher to 404 and 500 series error responses, as well as communicate that everything is just fine.

A 404 server response is called an error only because the browser or crawler’s request for a webpage was made in error because the page does not exist.

It doesn’t mean that your site is in error.

If another site (or an internal link) links to a page that doesn’t exist, the coverage report will show a 404 response.

Clicking on one of the affected URLs and selecting the Inspect URL tool will reveal what pages (or sitemaps) are referring to the non-existent page.

From there you can decide if the link is broken and needs to be fixed (in the case of an internal link) or redirected to the correct page (in the case of an external link from another website).

Or, it could be that the webpage never existed and whoever is linking to that page made a mistake.

If the page doesn’t exist anymore or it never existed at all, then it’s fine to show a 404 response.

Taking Advantage Of GSC Features

The Performance Report

The top part of the Search Console Performance Report provides multiple insights on how a site performs in search, including in search features like featured snippets.

There are four search types that can be explored in the Performance Report:

  1. Web.
  2. Image.
  3. Video.
  4. News.

Search Console shows the web search type by default.

Change which search type is displayed by clicking the Search Type button:

Default search typeScreenshot by author, May 2022

A menu pop-up will display allowing you to change which kind of search type to view:

Search Types MenuScreenshot by author, May 2022

A useful feature is the ability to compare the performance of two search types within the graph.

Four metrics are prominently displayed at the top of the Performance Report:

  1. Total Clicks.
  2. Total Impressions.
  3. Average CTR (click-through rate).
  4. Average position.
Screenshot of Top Section of the Performance PageScreenshot by author, May 2022

By default, the Total Clicks and Total Impressions metrics are selected.

By clicking within the tabs dedicated to each metric, one can choose to see those metrics displayed on the bar chart.

Impressions

Impressions are the number of times a website appeared in the search results. As long as a user doesn’t have to click a link to see the URL, it counts as an impression.

Additionally, if a URL is ranked at the bottom of the page and the user doesn’t scroll to that section of the search results, it still counts as an impression.

High impressions are great because it means that Google is showing the site in the search results.

But, the meaning of the impressions metric is made meaningful by the Clicks and the Average Position metrics.

Clicks

The clicks metric shows how often users clicked from the search results to the website. A high number of clicks in addition to a high number of impressions is good.

A low number of clicks and a high number of impressions is less good but not bad. It means that the site may need improvements to gain more traffic.

The clicks metric is more meaningful when considered with the Average CTR and Average Position metrics.

Average CTR

The average CTR is a percentage representing how often users clicked from the search results to the website.

A low CTR means that something needs improvement in order to increase visits from the search results.

A higher CTR means the site is performing well.

This metric gains more meaning when considered together with the Average Position metric.

Average Position

Average Position shows the average position in search results the website tends to appear in.

An average in positions one to 10 is great.

An average position in the twenties (20 – 29) means that the site is appearing on page two or three of the search results. This isn’t too bad. It simply means that the site needs additional work to give it that extra boost into the top 10.

Average positions lower than 30 could (in general) mean that the site may benefit from significant improvements.

Or, it could be that the site ranks for a large number of keyword phrases that rank low and a few very good keywords that rank exceptionally high.

In either case, it may mean taking a closer look at the content. It may be an indication of a content gap on the website, where the content that ranks for certain keywords isn’t strong enough and may need a dedicated page devoted to that keyword phrase to rank better.

All four metrics (Impressions, Clicks, Average CTR, and Average Position), when viewed together, present a meaningful overview of how the website is performing.

The big takeaway about the Performance Report is that it is a starting point for quickly understanding website performance in search.

It’s like a mirror that reflects back how well or poorly the site is doing.

Performance Report Dimensions

Scrolling down to the second part of the Performance page reveals several of what’s called Dimensions of a website’s performance data.

There are six dimensions:

1. Queries: Shows the top search queries and the number of clicks and impressions associated with each keyword phrase.

2. Pages: Shows the top-performing web pages (plus clicks and impressions).

3. Countries: Top countries (plus clicks and impressions).

4. Devices: Shows the top devices, segmented into mobile, desktop, and tablet.

5. Search Appearance: This shows the different kinds of rich results that the site was displayed in. It also tells if Google displayed the site using Web Light results and video results, plus the associated clicks and impressions data. Web Light results are results that are optimized for very slow devices.

6. Dates: The dates tab organizes the clicks and impressions by date. The clicks and impressions can be sorted in descending or ascending order.

Keywords

The keywords are displayed in the Queries as one of the dimensions of the Performance Report (as noted above). The queries report shows the top 1,000 search queries that resulted in traffic.

Of particular interest are the low-performing queries.

Some of those queries display low quantities of traffic because they are rare, what is known as long-tail traffic.

But, others are search queries that result from webpages that could need improvement, perhaps it could be in need of more internal links, or it could be a sign that the keyword phrase deserves its own webpage.

It’s always a good idea to review the low-performing keywords because some of them may be quick wins that, when the issue is addressed, can result in significantly increased traffic.

Links

Search Console offers a list of all links pointing to the website.

However, it’s important to point out that the links report does not represent links that are helping the site rank.

It simply reports all links pointing to the website.

This means that the list includes links that are not helping the site rank. That explains why the report may show links that have a nofollow link attribute on them.

The Links report is accessible  from the bottom of the left-hand menu:

Links reportScreenshot by author, May 2022

The Links report has two columns: External Links and Internal Links.

External Links are the links from outside the website that points to the website.

Internal Links are links that originate within the website and link to somewhere else within the website.

The External links column has three reports:

  1. Top linked pages.
  2. Top linking sites.
  3. Top linking text.

The Internal Links report lists the Top Linked Pages.

Each report (top linked pages, top linking sites, etc.) has a link to more results that can be clicked to view and expand the report for each type.

For example, the expanded report for Top Linked Pages shows Top Target pages, which are the pages from the site that are linked to the most.

Clicking a URL will change the report to display all the external domains that link to that one page.

The report shows the domain of the external site but not the exact page that links to the site.

Sitemaps

A sitemap is generally an XML file that is a list of URLs that helps search engines discover the webpages and other forms of content on a website.

Sitemaps are especially helpful for large sites, sites that are difficult to crawl if the site has new content added on a frequent basis.

Crawling and indexing are not guaranteed. Things like page quality, overall site quality, and links can have an impact on whether a site is crawled and pages indexed.

Sitemaps simply make it easy for search engines to discover those pages and that’s all.

Creating a sitemap is easy because more are automatically generated by the CMS, plugins, or the website platform where the site is hosted.

Some hosted website platforms generate a sitemap for every site hosted on its service and automatically update the sitemap when the website changes.

Search Console offers a sitemap report and provides a way for publishers to upload a sitemap.

To access this function click on the link located on the left-side menu.

sitemaps

The sitemap section will report on any errors with the sitemap.

Search Console can be used to remove a sitemap from the reports. It’s important to actually remove the sitemap however from the website itself otherwise Google may remember it and visit it again.

Once submitted and processed, the Coverage report will populate a sitemap section that will help troubleshoot any problems associated with URLs submitted through the sitemaps.

Search Console Page Experience Report

The page experience report offers data related to the user experience on the website relative to site speed.

Search Console displays information on Core Web Vitals and Mobile Usability.

This is a good starting place for getting an overall summary of site speed performance.

Rich Result Status Reports

Search Console offers feedback on rich results through the Performance Report. It’s one of the six dimensions listed below the graph that’s displayed at the top of the page, listed as Search Appearance.

Selecting the Search Appearance tabs reveals clicks and impressions data for the different kinds of rich results shown in the search results.

This report communicates how important rich results traffic is to the website and can help pinpoint the reason for specific website traffic trends.

The Search Appearance report can help diagnose issues related to structured data.

For example, a downturn in rich results traffic could be a signal that Google changed structured data requirements and that the structured data needs to be updated.

It’s a starting point for diagnosing a change in rich results traffic patterns.

Search Console Is Good For SEO

In addition to the above benefits of Search Console, publishers and SEOs can also upload link disavow reports, resolve penalties (manual actions), and security events like site hackings, all of which contribute to a better search presence.

It is a valuable service that every web publisher concerned about search visibility should take advantage of.

More Resources:


Featured Image: bunny pixar/Shutterstock





Source link

Continue Reading

SEO

New Updates To Google Page Experience Scoring Revealed At SEODay

Published

on

New Updates To Google Page Experience Scoring Revealed At SEODay


In an online session at SEODay 2022, Google Search Advocate John Mueller spoke about the impact of page experience on search engine rankings and changes to how the search engine scores sites.

One of the changes revealed was that Google now bases desktop search results on a site’s desktop experience – and mobile search results on a site’s mobile experience.

He also discussed the three primary metrics the search engine uses in determining experience scores: largest contentful paint (LCP), first input delay (FID), and cumulative layout shift (CLS).

“This is not a tie-breaker,” Mueller said. “It won’t make or break your website in terms of search, but it is a factor that comes into play in regards to ranking between different results.”

Google has also added a new page experience metric, “interactivity to next page,” or INP.

Google initially announced INP at I/O 2022, and while Mueller was clear that it is not a direct rankings factor, he discussed INP  as something that may play a role in the future.

Search Console Insights Provides Easier Way To Track Search Rankings

Mueller spent the first part of his presentation discussing the benefits of Search Console Insights. Using Search Console data, alongside analytics, users can generate custom reports and get a different view of the data.

He specifically mentioned using BigQuery and Data Studio as “a way of connecting different data sources together and creating really fancy reports.”

Google is also working on expanding its Search Console APIs, Mueller said, which will allow users to connect these APIs to code on their sites.

Possible uses Mueller mentioned include monitoring top queries and checking to see if specific URLs are indexed.

Videos & Images Take On More Prominent Role In Search

At I/O earlier this year, Google previewed a set of video reports coming to Search Console: a response to a growing appetite for this type of media in search results.

“We see that people love videos and authentic images in search results, so we try to show them more,” Mueller said.

In this growing trend, he included web stories, a collection of pages that often have videos. To facilitate their use, Google now offers a WordPress plugin for creating them.

Authentic Product Reviews Factored Into Rankings

Ecommerce has been trending upward, with the global market expected to surpass $5.5 trillion this year. In its algorithm, Google includes what Mueller termed “authentic reviews” to accommodate digital shoppers better.

“People have high expectations of reviews they find online, so we’ve also worked specifically on updates to algorithms with regards to ranking these product reviews,” he said.

Other Updates From Mueller

At SEODay, Mueller said Google has slightly changed its terminology, with the term “title links” now being used to refer only to the title of a search result.

The search engine giant has also added a new robots meta tag, “indexifembedded.”

Users can leverage the meta tag when embedding content on the main page and want to control the indexing of that embedded piece of content.

Mueller also said Google’s blog was the best source of information on any SEO-related topic.

“With any kind of bigger update… it’s sometimes really tricky to tell folks what they should be looking at specifically,” he noted. “So we have a fairly comprehensive blog post .”


Featured Image: BestForBest/Shutterstock





Source link

Continue Reading

SEO

Making Python Scripts Work In Browser For Web App Creation

Published

on

Making Python Scripts Work In Browser For Web App Creation


Making Python Scripts work in a web browser involves handling web app functions inside a web page via Python Programming Language.

Since JavaScript is the main programming language for making a web browser work, and a web page interactive, Python is usually used for data science, machine learning, and artificial intelligence.

Even if we have back-end infrastructures like Django, and Flask, or static-site-generators like Jekyll, Python is usually behind JavaScript for web development.

But thanks to the latest improvements, JavaScript’s future is open to discussion. “PyScript” allows Python Scripts to work easily within web components.

According to PyScript.net:

“PyScript is a framework that allows users to create rich Python applications in the browser using HTML’s interface and the power of PyodideWASM, and modern web technologies. The PyScript framework provides users at every experience level with access to an expressive, easy-to-learn programming language with countless applications.

In this column, you’ll learn what PyScript is, see an example, learn about alternatives, and also find how to create a custom web app with Python and PyScript.

What Is The JavaScript To Python Migration?

Python is a human-readable programming language.

Thus, there are many Python intermediary program languages to help JavaScript and Java modules and packages are being used in the Python environment.

For example, “TensorFlow” is mainly a JS Package, or Plotly and Selenium.

There are even special packages to make JavaScript code turn into Python code, such as Js2Py.

Why is understanding JavaScript behind Python important?

Because using Python Scripts inside the web browser doesn’t mean that the age of JavaScript is ending for web development.

JavaScript is still functioning behind the Python Scripts in the web browser.

What Is PyScript & How Can You Use It For Creating Web Applications?

PyScript is a framework for making web browsers use Python Scripts.

PyScript turns Python code blocks into Javascript equivalents behind the scenes.

To use PyScript inside a web browser, follow these steps.

Use the stylesheet and JavaScript in the <head> area of the HTML File.

<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />

<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
  • Use the Python Code inside the “<pyscript></pyscript>” web component.
  • Pay attention to the indentation.
  • Do not format the Python code inside the “<pyscript/>” web component.
  • Use the shortcuts and arguments of the PyScript for importing Python modules and packages.
  • Use the CSS Classes and IDs to insert the results into the HTML Documents’ specific Div.

An Example Of Running Python Script Inside Of Web Browser

An example of running a Python script in the browser is below.

<html>
<head>
     <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
     <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
          crossorigin="anonymous">
     <py-env>
- numpy
- matplotlib
     </py-env>
</head>

The <head> area of the HTML File represents the most important resources.

We used the “pyscript.css” and “pyscript.js.”

We also used the “<py-env/>” web component to make the Python modules to be imported.

In this example, we have imported the “numpy” and “matplotlib.”

In the “<body>” section, we will use these modules to create a Python Line Plot inside a web browser.

<body>
     <h1>Let's plot random numbers</h1>
     <div id="plot"></div>
     <py-script output="plot">

At the beginning of the <body>, we used a “div” with the “plot” ID.

It is necessary for making the Python script’s output insertion.

The “<py-script output=”plot”>” is necessary to match the specific HTML Div’s ID value.

 import matplotlib.pyplot as plt

 import numpy as np
 
 x = np.random.randn(1000)

 y = np.random.randn(1000)

 fig, ax = plt.subplots()
 ax.scatter(x, y)
 fig
     </py-script>
</body>
</html>

The Python Script above is a simple line plot script. And you can see the result below.

Screenshot by author, June 2022

The example above shows how to create a line plot with the help of PyScript.

How To See The Terminal Output Of The PyScript

For every Python Script, there is always a terminal that works and outputs the messages from the computation process.

Pyscript ConsoleScreenshot by author, June 2022

The browser console should be read and followed by the developer to see how the PyScript works and what happens behind the scenes.

For example, the screenshot above shows the running process of the Python script that we have created.

It explains how the “numpy”, or “matplotlib” and their dependencies are loaded, and used by which resource.

How To Create a Custom Web App With Python And PyScript?

To create a custom Web App with Python and PyScript, follow these steps:

  • Import the necessary JS and CSS files from PyScript.
  • Create an HTML Document with proper HTML Tag syntax.
  • Use the “py-script” HTML tag with the “output” attribute.
  • Use an HTML Div with a specific ID to match the “output” attribute value.
  • Use “py-env” for the non-built-in libraries of Python.
  • Insert Python Script inside the “py-script” tag without syntax and indentation error.
  • Use “return” in a Python function, or “print” to end your script.
  • Refresh the web page to see the results.

An example of a Custom Python Web App for “random password generation” based on the given password length is below.

Python Web App CreationScreenshot by author, June 2022

The screenshot above demonstrates an example of PyScript in an HTML Document to generate custom passwords.

The Python script that I used is below.

import string
import random
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")
def generate_random_password():
    length = int(input("Enter password length: "))
    random.shuffle(characters)
    password = []
    for i in range(length):
        password.append(random.choice(characters))
    random.shuffle(password)
    print("".join(password))
generate_random_password()

And, the live version of the custom Python Web App is here.

Just write a numeric value into the input area.

Input AreaScreenshot by author, June 2022

And, it will give you a simple 45-character password.

SEJ Custom Python AppScreenshot by author, June 2022

You can use this technology for some of my other SEJ Articles for auditing sitemaps, or visualization of hot topics from news websites.

Or, in the future, we can demonstrate more sophisticated web apps via PyScript.

What Are The Disadvantages Of PyScript?

The main disadvantage of PyScript is the lack of support.

PyScript is announced during Pycon 2022 to Python developers.

It was a big and exciting event, but community expectations were higher than the current state of PyScript.

Due to weak community support, PyScript development might be slower in the future, but when we think of the journey of Python, it is not surprising.

Python wasn’t that popular until the last five years, because it wasn’t known.

Python Search TrendsScreenshot by author, June 2022

Above, you can see how Python suppressed the search demand of JavaScript overall.

The main reason for Python’s popularity growth is the “pandas” library.

That’s why, ML and Data Science are the main focuses of Python, but it doesn’t have to continue in that way.

Thus, PyScript should be taken into serious consideration for the future of web development.

Pyscript Search DemandScreenshot by author, June 2022

What Are The Alternatives To PyScript?

Alternatives to PyScript are not equivalent to PyScript since it directly runs on the browser, but still, there are different methods to use Python scripts inside a website indirectly.

These included “brython”, “pyodide”, “Appwrite”, “django-readers”, “appdeamon”.

Some alternatives to PyScript are for Firebase such as Appwrite, and some other work for Web Development such as Brython.

Bryhthon for Web App Creation

Brython is older than Pyscript, and it focuses on making Python the primary language for web development with “text/python” file type instead of “text/javascript”.

Can PyScript And Brython Affect Search Engines And SEO?

Yes, in the future, PyScript and Brython can increase their effect on the web development industry.

Changing web development technologies and industries affect search engine crawlers and protocols.

If a search engine starts to see “text/python” files, or “.py” scripts in the HTML source code, it should be able to make it work to see the web page as is.

At the moment, PyScript works via JavaScript, and Brython is already at the beginning of its journey despite its being older.

Other PyScript alternatives work via Node.js like back-end programming libraries, or Firebase like cloud-based systems.

Thus, in the future, Google, as a heavily Python-coded search engine, might need to render Python files for crawling and rendering web pages.

Conclusion For Python As Web Scripting

For people who love coding, it doesn’t matter whether you use Python or JavaScript for a certain task.

But, Python is the easiest programming language to learn as human-readable, it gives more functionality with fewer characters.

Most data scientists and ML (machine learning) Engineers know Python in a good way, and transferring their talents into web development would be similar to the unification of two different universes.

More resources:


Featured Image: TippaPatt/Shutterstock





Source link

Continue Reading

Trending

Copyright © 2021 Liveseo.com